[an error occurred while processing this directive]
Certain types of form objects, such as checkboxes and menus can't have a text cursor, so they can't trigger an onBlur event when you make changes. You can use the onChange event to trigger your functions when the user has make his/her selec tion on these items.
<SCRIPT> function getSelect(s) { return s.options[s.selectedIndex].value } </SCRIPT>
<FORM> |
Since Netscape forgot to provide a function for getting the value of a select box, I wrote one which I place in the <SCRIPT> tags of any page that has a selection list. Simply copy the getSelect(s) function into your <SCRIPT> area, and getSelect(form.mylist) will return the Value of the current mylist selection.
In this example we used the word this as a shortcut. We could have said getSelect(form.list), however since the command was inside the <SELECT> tag, the word this automatically referred to the current <SELECT> object. In this example, if Lycos was selected, then the event onChange="location=getSelect(this)" would be interpreted as location="http://www.lycos.com".
Since a checkbox is selected/deselected with a mouse click, the onClick event will trigger your function whenever the checkbox is changed. Each checkbox has a property called checked which is equal to true or false depending on whether the box is currently checked. This example runs a function when the box is clicked, and displays a message if the box is checked.
function rushbox(checked) { if (checked==true) {alert(" LIFT OFF! ")} } |
<FORM> <INPUT TYPE=checkbox NAME="rush" OnClick="rushbox(form.rush.checked)" Rush this order <FORM> |
Page Load events |