By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,568 Members | 1,196 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,568 IT Pros & Developers. It's quick & easy.

select input problem

P: 107
hey guys,

any idea why this doesnt work in IE:

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <script language="javascript">
  4. function add(){
  6.     newoptions = "<option>1<option>2";
  7.     sel = document.getElementById('myselect');
  8.     sel.innerHTML += newoptions;
  10. }
  11. </script>
  12. </head>
  13. <body>
  14. <select id="myselect">
  15. </select>
  18. <a href="#" onclick="add();">add options</a>
  19. </body>
  20. </html>

Works with other browsers but IE is being its awkward little self!


Jul 10 '08 #1
Share this Question
Share on Google+
4 Replies

Expert 100+
P: 1,654
Appending the code with innerHTML won't work in IE.

See this example.
Jul 10 '08 #2

P: 107
ah ok thanks.

God i love IE. why cant it just do both like all the others!
Jul 10 '08 #3

Expert Mod 15k+
P: 16,027
Even the add() method is not supported properly which is why you need a try/catch. You could also use the options array to add options:
Expand|Select|Wrap|Line Numbers
  1. selObj.options[i] = opt;
Jul 10 '08 #4

P: 107
how do they get away with makes peoples lives such hard work!?!?

I've made an app and everything i've done has worked perfectly in firefox no questions, but IE bitches and moans all the way, and it doesn't even help you debug... "error on page".... yea but where?!!
Jul 10 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.