Selectbox: Catch an onchange event that was TRIGGERED by external JavaScript? -
Please read the title carefully - this is not common.
There exists a selectbox selection box on a webpage, its selected index is programmatically javascript, External JS.
, when I change the index (Crossbrower solution). Is this possible?
or HTML:
& lt; Select id = "myselect" & gt; & Lt; Options & gt; Opt-1 & lt; / Options & gt; & Lt; Options & gt; Opt 2 & lt; / Options & gt; & Lt; Options & gt; Option 3 & lt; / Options & gt; & Lt; / Select & gt;
Javascript:
// code can not manipulate var select = document.getElementById ("myselect"); Select.selectedIndex = 2; // I have to notify now
is waiting for your information: -)
Update:
This is the answer to my basic question I did not, but by using this I managed to accomplish what I initially wanted (not part of the post):
select.selectedIndex = 2; Select.onchange (); Javascript conversion events require a user-initiated browser event.
If you want to do this really really , then you should write a task that is & Lt; Select & gt;
, and compares set interval
at regular intervals using
var selectold = select.selectedIndex; SetInterval (function (if (selectold! = Select.selectedIndex) {console.log ("There was a change"); selectold = select.selectedIndex;}}, 500);
Edit
Comments
Post a Comment