ok, i have a select dropdown and beneeath it is a text field. If I poplate a static text field and onclick of its option i want to fill in the text field with the values selected in select dropdown. It works fine.
here is a
Now I am pulling the select dropdown options ffrom the xml and when I again use it to update my text field on click of its option, it doesn’t work;
Here is a DEMO
i know that in the second demo, the xml is not at the correct place, but I have tested this on my local machine and it doesn’t work.
Any help is appreciated.
Thanks
I assume you’re actually using multiple selects. If so, just bind the handler to the
selectelement instead:This finds the selected element when clicked, and doesn’t need to be bound to the individual
optionelements after they’re inserted.If you’re not using a multiple, you’d want to bind to the
changeevent.Ultimately, what was happening was that the asynchronous AJAX call was executing its callback function after you ran the code to bind the handlers.
In other words, code doesn’t wait for the AJAX response to arrive before it executes. By binding to the
selectitself, you know it is already available in the document, so there’s no synchronization issues.