my select option in HTML is,
<select name="id" id="id" style="width:400px;" onChange="loadAjax(this.value);">
<select name="name" id="name" style="width:400px;">
Which loads the ajax function (using javascript) when the value is change in SELECT (html).
But I am in different requirement, that when this select input loads, it should call the loadAjax function directly, and on change as well.
How it could be possible?
I tried some things like window.onload, onload, but nothing worked.
Given that you’ve tagged your question with “jquery”, I’d suggest a jQuery solution:
This defines the change handler and then immediately triggers it. (You would remove the inline
onclickfrom your html.)Or without jQuery perhaps something like this: