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
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/ >

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.