fill select (drop down) element dynamically
I have a select (combo box) element that gets filled with items when selected item changed in another one (master combo box). It works in Chrome, FireFox but not in IE (all latest browser versions).
How do I populate the items in the child combo box:
- ajax call of a PHP script
- that returns items for the combo box: echo '<option value="' . $id . '">' . $name . '</option>';
- setting innerHTML attribute of the child combo box to a value that gets returned by the ajax call: document.forms['parametersForm'].elements['stationId'].innerHTML = html;
Thanks for your future help!
It should work just fine in IE if it's coded right.
Maybe if you showed the code you are using now????
FWIW, for a simple list of <option>s you probably don't need to use JSON. Just returning a list of string values would surely work fine. But there's also no reason JSON shouldn't work.
the problem is that the innerHTML attribute of a select element cannot be set in IE. It does not cause an error, but it does not work.
The following example does not work in IE, but it works in Firefox, Chrome, Safari and Opera:
If someone wants to know more about that, I can provide additional info.
Yep, would have suggested doing exactly that if I'd read the original post more carefully where you said you were trying to use innerHTML. The 2D array from JSON is better suited for creating Option elements, anyway, rather than using innerHTML.
|All times are GMT +1. The time now is 08:20 AM.|
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.