JSFiddle - React, Tailwind, and code Playground
HTML
<form>
<input type="checkbox" id="asdf" />
</form>
JavaScript
function AddressBookEntryObj(user, selectField) {
this.selectField = selectField;
this.user = user;
this.makingRequest = false;
this.debugMode = false;
Event.observe(this.selectField, 'change', handleEvent.bind(this));
}
//Prototype statements
AddressBookEntryObj.prototype.handleEvent = handleEvent;
//End prototype statements
function handleEvent(e) {
alert(this.user); // your addressbook
alert(e.target); // the form element
try {
if (!this.makingRequest) {
this.makingRequest = true;
var ajax =
new Ajax.Request('/servlet/MyReallyCoolServlet', {
method: 'get',
parameters: {
action: 'doGet',
whichFunc: 'MyReallyCoolFunction',
fieldValue: $(this).getValue(),
user: this.user
},
onCreate: handleAjaxCreate,
onComplete: handleChangeComplete
});
return true;
}
else {
return false;
}
}
catch (ex) {
alert("handleEvent Error: \r\n" + ex.toString());
}
}
var a = new AddressBookEntryObj('me', document.getElementById('asdf'));