This is the url of my page : http://www.animalswecare.com/Ads/postad.php There are two fields category and sub category , when category is selected , sub category changes respectively , it is working fine in google chrome , but it has problem with IE, in IE subcategory does not change when category is selected.
-
I think this answer will help you: http://stackoverflow.com/questions/6380304/dynamically-populate-dynamically-created-select-list – Niklas Oct 20 '11 at 08:20
4 Answers
I encourage you to use jQuery for things like that because they make sure it will work accross almost every browser. Its very easy.

- 60,192
- 27
- 155
- 202
-
I second that, jQuery or other frameworks are crossbrowser, have a look at them. – JNDPNT Oct 20 '11 at 08:07
You are giving id "txtHint" to the select element which is wrong, assign this id to its parent element i.e; TD like
<td id="txtHint"><select name="sub_category"></select></td>

- 9,703
- 8
- 38
- 54
you cannot set innerHTML for a select.
instead, you create a <div id="txtHintWrapper"></div>
when you do the innerHTML update, include <select></select>
there

- 1,960
- 1
- 19
- 32
There's a javascript error in this line:
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
It's a known bug.Take a look at this MSDN bug report for a workaround: BUG: Internet Explorer Fails to Set the innerHTML Property of the Select Object.
This question talks about it too, and might also be useful: Javascript - innerHTML not working with HTML select menus.
But seeing that the Ajax Request returns the whole <select>
tag, you should be replacing the parent <td>
's innerHTML
, not the <select>
's, as @dev just pointed out.

- 1
- 1

- 27,550
- 11
- 97
- 161