Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Adding option elements to html select control

 
Gamini Sirisena
Ranch Hand
Posts: 378
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My HTML and javascript looks like this..



Is this correct and standards compliant?
 
Sapika Am
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
//use <new Option(text, value, defaultSelected, selected)> instead

// example

var allItems = document.getelementById('allItems');
allItems[2] = new Option('New Element');
 
Sapika Am
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
select elements option is stored in array
 
Gamini Sirisena
Ranch Hand
Posts: 378
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have already gone through this thread already.

My question is where can I find the specifications/API for
the Options object?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64827
86
IntelliJ IDE Java jQuery Mac Mac OS X
 
Gamini Sirisena
Ranch Hand
Posts: 378
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've checked this too.

Can you help with interpreting this?

I believe the relevant section is this for the html option element?

How do I derive "new Option(text, value, defaultSelected, selected)" from this reference?
How do I know "Option" is the class name to use?
And how do I figure out the number of parameters and their types for the constructor?
[ October 08, 2008: Message edited by: Gamini Sirisena ]
 
Gamini Sirisena
Ranch Hand
Posts: 378
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've found this link that describes the constructors for the HTML objects.

I couldn't find an authoritative site with this information. I am unable to use http://www.w3.org/TR/DOM-Level-2-HTML/html.html to find information regarding this.

Can anybody clear this out for me?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic