473,326 Members | 2,090 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Select.appendChild(Option) doesnt work in IE

I am trying to set the value for a select list..the code is as below...It works fine in firefox, but dosent work in IE ...need urgent help ...

__________________________________________________ _______________
Expand|Select|Wrap|Line Numbers
  1. var Name="<%=value%>";
  2.  
  3.  
  4.            var oForm = parent.window.opener.document.mainForm;
  5.             var oSelect = oForm.elements["users1"];
  6.             var oOptions = oSelect.options;
  7.             var bAdd = true;
  8.             if (oOptions) {
  9.                 for (var i=0; i < oOptions.length; i++) {
  10.                     if (oOptions[i].value == Name) {
  11.                         bAdd = false;
  12.                     }
  13.                 }
  14.             }
  15.             if (bAdd) {
  16.                 var oOption = document.createElement("OPTION");
  17.                 oOption.setAttribute("value", Name);
  18.                 oOption.appendChild(document.createTextNode(Name));
  19.                 oSelect.appendChild(oOption);
  20.             }
  21.  
__________________________________________________ _______________
I tried using this code which I find in some other site, but this also didnt work

Expand|Select|Wrap|Line Numbers
  1. if (document.all) { // IE
  2.                 select.add(opt);
  3.             }
  4.             else {
  5.                 select.appendChild(opt);
  6.             }
  7.  
need urgent help ..thanks in advance
Nov 27 '07 #1
2 8313
mrhoo
428 256MB
IE up to 6 doesn't know about option childNodes.
Set the option's text property instead- it works in more modern browsers as well.

oOption.text=Name;
Nov 27 '07 #2
mrhoo
428 256MB
IE up to 6 doesn't know about option childNodes.
The option gets added to the select, but it has no text content.


Set the option's text property instead- it works in more modern browsers as well.

Option.text=Name;
Nov 27 '07 #3

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

Similar topics

1
by: Michael Hoffmann | last post by:
Hello, As you might guess I am completely new to this language. Maybe I get some help here. I try to execute a user defined funciton from a select option in a document to read a file into an...
3
by: J. Muenchbourg | last post by:
I have an ASP admin script where I'm adding records, and I have a category that already has set name values hard-coded into a selct option pulldown, but if the user wants to create a new category...
4
by: Jeff Anderson | last post by:
Is there a style for a select option's "selected" color? For example: <HTML> <BODY> <FORM NAME="form1"> <SELECT NAME="mySelect" SIZE="7" style="background-color:red;"> <OPTION>Test 1...
4
by: Old Lady | last post by:
Hi, I need help! I have a SELECT/OPTION list. My goal is to have a TEXT input field in a form that is normally disabled, but it should become enabled when the user select one predefined OPTION....
11
by: Stefan Finzel | last post by:
Hi trying to remove one or all elements of select options fails for Pocket Internet Explorer. Is there a way to do this? if is_PIE { // this does not work on Pocket IE while (opt.length) {...
2
by: shagy | last post by:
Hi, I'm having a problem with a <select><option> which has white space in values... When I post the data I only get the first word (up to the white space). "Testing white space" becomes...
1
by: kirke | last post by:
I want to load textarea's value in drop-down box. In first page, such form is existed. <form name="form1" method="post" action="next.php"> <textarea name="dayList" Id = "dayList" cols=20...
1
by: aamirghanchi | last post by:
I guess, the visibility and display styles of an OPTION in a SELECT list cannot be changed through javascript. I wanted to make some options unavailable depending on a situation eg. <select>...
3
by: pravinnweb | last post by:
Hi i have select option in my page which works fine in firefox in which i mention specific width for select option when i clicked select list the option lengths are large the option area is expanded...
7
by: fsalvador | last post by:
Hi, I am trying to figure it out how to to hide in onmouseout the select options of a form. Below is the code I got so far. It isn't working. Please help. Thanks <!DOCTYPE HTML PUBLIC...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.