This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes DOM and adding a brand new select list Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply Bookmark "DOM and adding a brand new select list" Watch "DOM and adding a brand new select list" New topic
Author

DOM and adding a brand new select list

Rob Hunter
Ranch Hand

Joined: Apr 09, 2002
Posts: 788
Can anyone tell me or show me how I can dynamically add a new row to a table and in one of the newly added cells add a brand new select list? The cells I'm adding using DOM are fine but when I try putting in the select list it doesn't work. For example, if I try and set the cell's innerText it just displays the tag for the select list. If I try and set the innerHtml it gives me nothing. Any help would be appreciated. Thanks.

Rob
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56191
    
  13

Where's your code?


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15357
    
    6
with a select you should be use new Option()



Eric
binayakumar patel
Greenhorn

Joined: Jun 26, 2009
Posts: 27
This may Help you.
binayakumar patel
Greenhorn

Joined: Jun 26, 2009
Posts: 27
Inplace of

# var option1 = document.createElement("OPTION")
# option1.text="Banana"
# option1.value=1
# selectBox.options.add(option1)

We can use:

selectBox.options[selectBox.options.length]=new Option("Banana","1")
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: DOM and adding a brand new select list
 
Similar Threads
Help on using layout manager
returning information from an object
Game Of Life, some questions
Can I add an arrow onto a shape in a GridLayout?
Head First Java - Chapter 5