aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Adding option elements to html select control Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Adding option elements to html select control" Watch "Adding option elements to html select control" New topic
Author

Adding option elements to html select control

Gamini Sirisena
Ranch Hand

Joined: Aug 05, 2008
Posts: 378
My HTML and javascript looks like this..



Is this correct and standards compliant?
Sapika Am
Greenhorn

Joined: Jan 15, 2008
Posts: 10
//use <new Option(text, value, defaultSelected, selected)> instead

// example

var allItems = document.getelementById('allItems');
allItems[2] = new Option('New Element');
Sapika Am
Greenhorn

Joined: Jan 15, 2008
Posts: 10
select elements option is stored in array
Gamini Sirisena
Ranch Hand

Joined: Aug 05, 2008
Posts: 378
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

Joined: Jan 10, 2002
Posts: 61760
    
  67

http://www.w3.org/TR/DOM-Level-2-HTML/html.html


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Gamini Sirisena
Ranch Hand

Joined: Aug 05, 2008
Posts: 378
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

Joined: Aug 05, 2008
Posts: 378
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?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Adding option elements to html select control