jesh 0 Posted April 9, 2007 Report Share Posted April 9, 2007 It had been a few months since I was faced with dynamically creating a drop down menu using the DOM so I turned (as I always do) to the tutorials on the site - specifically here:http://www.w3schools.com/htmldom/met_select_add.aspThe solution, as it is presented, doesn't work cross-browser. I suggest updating it to something like this:BEFORE: function insertOption() { var y=document.createElement('option'); y.text='Kiwi' var x=document.getElementById("mySelect"); try { x.add(y,null); // standards compliant } catch(ex) { x.add(y); // IE only } } AFTER: function insertOption(){ var y = document.createElement('option'); y.appendChild(document.createTextNode('Kiwi')); var x = document.getElementById("mySelect"); x.appendChild(y);} This way it'll work, at least, on the PC using Firefox 2.0, IE 6.0, Opera 9.1 and on the Mac using Firefox 1.5 and Safari (didn't check the version). The solution, as currently presented, doesn't work at all in Safari. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.