Search

11/17/2009

scripiting form elements

"An important thing to know about event handlers is that within the code of an event handler, the this keyword refers to the document element that triggered the event. Since all form elements have a form property that refers to the containing form, the event handlers of a form element can always refer to the Form object as this.form. Going a step further, this means that an event handler for one form element can refer to a sibling form element named x as this.form.x."


<form name="sample">
<input type="text" name="text">
</form>

docuemnt.sample.text.form == document.sample

* The <button> tag may be used anywhere in an HTML document and need not be placed within a <form>.

* When the user clicks on a toggle button, the radio or checkbox element triggers its onclick event handler to notify the JavaScript program of the change of state. Newer web browsers also trigger the onchange handler for these elements. Both event handlers convey the same essential information, but the onclick handler is more portable.

沒有留言: