473,386 Members | 1,720 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,386 software developers and data experts.

Question on HTML DOM Select Object

1
To clarify, the thing i'm trying to insert is,
http://www.w3schools.com/htmldom/dom_obj_select.asp


I have a table and i want to insert a select object into one of the cell. but i am getting a "Type mismatch" error on line with code "cell.insertBefore(selectBox);"


I am running IE 6

Expand|Select|Wrap|Line Numbers
  1.                   var selectBox = document.createElement('select');
  2.  
  3.                 var option = document.createElement('option');
  4.                 option.text = "And";
  5.  
  6.                 try
  7.                 {
  8.                     selectBox.add(option, null); // standards compliant
  9.                 }
  10.                   catch(ex)
  11.                 {
  12.                     selectBox.add(option); // IE only
  13.                 }
  14.  
  15.  
  16.             }
  17.  
  18.             cell5.insertBefore(selectBox);
  19.  
Thank you for your time
Dec 13 '07 #1
1 2628
rnd me
427 Expert 256MB
To clarify, the thing i'm trying to insert is,
http://www.w3schools.com/htmldom/dom_obj_select.asp


I have a table and i want to insert a select object into one of the cell. but i am getting a "Type mismatch" error on line with code "cell.insertBefore(selectBox);"


I am running IE 6

Expand|Select|Wrap|Line Numbers
  1.                   var selectBox = document.createElement('select');
  2.  
  3.                 var option = document.createElement('option');
  4.                 option.text = "And";
  5.  
  6.                 try
  7.                 {
  8.                     selectBox.add(option, null); // standards compliant
  9.                 }
  10.                   catch(ex)
  11.                 {
  12.                     selectBox.add(option); // IE only
  13.                 }
  14.  
  15.  
  16.             }
  17.  
  18.             cell5.insertBefore(selectBox);
  19.  
Thank you for your time
you have an extra " } " in this snippit...

you might only be able to add to selects already merged into the document.

i try to avoid try/catch in my code.
the following syntax avoids the try/catch, and works across browsers:

Expand|Select|Wrap|Line Numbers
  1. var selectBox = document.createElement('select');
  2. selectBox.options[selectBox.options.length]= new Option ("And", "valueHere");
  3.  
  4.  
  5. //also: to delete all the options in a list:
  6. selectBox.options.length=0;
  7.  
  8.  
  9.  
Dec 13 '07 #2

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

Similar topics

4
by: its me | last post by:
Let's say I have a class of people... Public Class People Public Sex as String Public Age as int Public Name as string end class And I declare an array of this class...
5
by: Jim Bo | last post by:
Hi, I have a drop down menu that is being populated by a query to the access database ---- Code --- Skill needed <SELECT size="1" NAME="SkillType" VALUE="SkillType"> <OPTION>...
2
by: Eshrath | last post by:
Hi, What I am trying to do: ======================= I need to form a table in html using the xsl but the table that is formed is quite long and cannot be viewed in our application. So we are...
9
by: beguigne | last post by:
Below is a snippet of a crude date picking routine for a form. I am a novice at this so, I am hitting my head at why when I select the day, the onChange event gives me a blank. What am I missing?...
0
by: Michelle Keys | last post by:
I am trying to call a print function to print a string from a database using javascript. Which is RC_DATA of Varchar2(2500). This is a javascript is not being used. I have a thing that needs to...
14
by: 42 | last post by:
Hi, Stupid question: I keep bumping into the desire to create classes and properties with the same name and the current favored naming conventions aren't automatically differentiating them......
12
by: Bishoy George | last post by:
I have a dataset called ds1 filled with 2 tables Employees and Customers from Northwind database. I have dropdownList called ddLastName with the following properties: ddLastName.DataSource =...
1
by: Marko Vuksanovic | last post by:
I used the following code for implementing a file upload progress indicator, using UpdateProgress Panel, though I have a problem that FileUpload.Has File always returns false. Any suggestions what...
2
by: Mad Scientist Jr | last post by:
>From an asp.net web page I want the user to open the results of a SQL query in Excel, as automatically as possible (ie not having to loop through columns, rows, in code). For this,...
6
by: Jorgen Bodde | last post by:
Hi all, I am using sqlite3 in python, and I wonder if there is a way to know if there are valid rows returned or not. For example I have a table song with one entry in it. The ID of that entry...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.