I have a javascript which currently gets called using the ‘onchange’ event.
<SELECT NAME="person<?PHP echo $i; ?>" id="person<?PHP echo $i; ?>" onchange="get(<? echo $i; ?>);">
This select input replies on me having chosen a selection from the drop down list. if the page is loaded and the select has a ‘selected’ attribute so that a selection is preloaded, the javascript is not called. How can I change this so that the script will be called on load for the existing selection and on change should the user change the option?
this does not work:
<SELECT NAME="person<?PHP echo $i; ?>" id="person<?PHP echo $i; ?>" onchange="get(<? echo $i; ?>);" onload="get(<? echo $i; ?>);">
Thanks for the help.
select does not have onload event. you can call onload function on body tag,
But for this function to work $i should be defined before body tag ,otherwise it will return a undefined error.