0

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.

user995426
  • 91
  • 2
  • 9
  • 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 Answers4

2

I encourage you to use jQuery for things like that because they make sure it will work accross almost every browser. Its very easy.

http://api.jquery.com/jQuery.ajax/

dknaack
  • 60,192
  • 27
  • 155
  • 202
1

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>
Riz
  • 9,703
  • 8
  • 38
  • 54
0

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

http://support.microsoft.com/kb/276228

Tommy
  • 1,960
  • 1
  • 19
  • 32
0

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.

Community
  • 1
  • 1
Xavi López
  • 27,550
  • 11
  • 97
  • 161