Jump to content

Dynamic Drop Down List (select list)


therainmaker53

Recommended Posts

Hi Guys,

 

I'm trying to create a drop down list (select list)using javascript, it works fine in FireFox but not in IE 6. (Not sure about 7)

 

The code I am using is:

 

var select = document.createElement('select');

select.setAttribute("name", "compChoice");

td2.appendChild(select);

 

td2 is a td table element which work fine when dynamically created in other parts of the application.

 

I also populate the select list using javascript from values from a xml document.

 

I would be very grateful if anyone had any ideas on how to solve this problem?

 

Thanks all,

 

Sean.

Link to comment
https://forums.phpfreaks.com/topic/38087-dynamic-drop-down-list-select-list/
Share on other sites

I'm trying to create a drop down list (select list)using javascript, it works fine in FireFox but not in IE 6. (Not sure about 7)

 

IE's support for the W3C DOM is patchy, especially in regard to select elements.

 

var select = document.createElement('select');

select.setAttribute("name", "compChoice");

td2.appendChild(select);

 

td2 is a td table element which work fine when dynamically created in other parts of the application.

 

Just set the select element's properties directly;

 

  select.name = 'compChoice';

 

 

To insert options, use

new Option()

.

 

<URL: http://www.quirksmode.org/js/options.html >

 

--

Fred

Javascript FAQ: <URL: http://www.jibbering.com/faq/ >

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.