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

inserting new html table row using Javascript?


I have a form built into an html table. One of the form elements is an
asp.net dropdownlist. For some options in the listbox, I want to insert a
new table row under the listbox to grab some more info for that option. For
example if someone chooses 'other', a user needs to type what other is.
Because more than one option needs more info, I do not want to have a
textbox for each of these options so as not to crowd the page but instead,
dynamically insert a new textbox if one of these options are chosen.

I also prefer to do this through clientside Javascript instead of a
roundtrip post.
Anyone has an example of Javascript to do this effect?
Tnanks.

Karim
Nov 18 '05 #1
1 5972
Karim,

Hopefully this will help.

Regards

Donald

//Get reference to table.
var Table = document.getElementById('ForecastEditor_tblForecas ts');

//Get reference to table body.
var TableBody = Table.firstChild;

//Create the new elements
var NewRow = document.createElement("tr");
var ActionsCell = document.createElement("td");
var StartDateCell = document.createElement("td");
var StartDateTextbox = document.createElement("input");
var EndDateCell = document.createElement("td");
var EndDateTextbox = document.createElement("input");
var ValueCell = document.createElement("td");
var ValueTextbox = document.createElement("input");

//Add textboxes to cells
StartDateCell.appendChild(StartDateTextbox);
EndDateCell.appendChild(EndDateTextbox);
ValueCell.appendChild(ValueTextbox);

//Add elements to row.
NewRow.appendChild(ActionsCell);
NewRow.appendChild(StartDateCell);
NewRow.appendChild(EndDateCell);
NewRow.appendChild(ValueCell);

//Add row to table
TableBody.appendChild(NewRow);

"Karim" <karim3411@!!yahoo!!.com> wrote in message
news:1i******************************@40tude.net.. .

I have a form built into an html table. One of the form elements is an
asp.net dropdownlist. For some options in the listbox, I want to insert a
new table row under the listbox to grab some more info for that option. For example if someone chooses 'other', a user needs to type what other is.
Because more than one option needs more info, I do not want to have a
textbox for each of these options so as not to crowd the page but instead,
dynamically insert a new textbox if one of these options are chosen.

I also prefer to do this through clientside Javascript instead of a
roundtrip post.
Anyone has an example of Javascript to do this effect?
Tnanks.

Karim

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Wim Roffal | last post by:
I want to insert an option into a select. I know you can do something like: - Myselect.options = new Option('Hello 3'); but that doesn't do what I want because it overwrites an existing option....
1
by: Ben | last post by:
Hi all, I'm trying to write inside a table cell from external javascript but am not successful. When I insert inside a form within <td...>, it works but does not work for normal table cell. My...
1
by: MQ | last post by:
I have been trying to insert a col tag using DOM but I can't seem to make it work. In the following script I create a table with rows and columsn. I tried to modify the column style, but doesn't...
2
by: j van c | last post by:
I have a menubar on my main page. when clicking on a menu item I want to open an existing htm page at a certain position in my main page I use no frames. It should be replacing a div-section....
11
by: Mellow Crow | last post by:
I had a problem in IE 6 when trying to insert a table using W3C DOM techniques. I found a solution and share it. :) Initially I had...... ********************** <!DOCTYPE html PUBLIC...
20
by: alice | last post by:
I'm doing some text swapping with javascript, got it working fine, but I would like the line to have line breaks and being a beginner, I don't even know if this is possible. So I have a line like...
1
by: javediq143 | last post by:
Hi All, This is my first post in this forum. I'm developing a CMS for my latest website. This CMS is also in PhP & MySQL. I'm done with the ADD section where the Admin can INSERT new records in...
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
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...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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.