Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > inserting new html table row using Javascript?

Reply
Thread Tools

inserting new html table row using Javascript?

 
 
Karim
Guest
Posts: n/a
 
      12-11-2003

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
 
Reply With Quote
 
 
 
 
Donald Simpson
Guest
Posts: n/a
 
      12-11-2003
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:1idrz1qrzc7fc$... .
>
> 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



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
inserting new row in a table using jdeveloper ORACLEJDEV Java 0 09-11-2008 11:39 AM
Inserting a new row. rcoco ASP .Net 3 03-01-2007 09:38 AM
row bottom border in inner table not matching up with row border in outer table phl HTML 1 06-08-2006 03:43 PM
ok I can do a totals row but how about a percentage row after each data row D ASP .Net Datagrid Control 0 05-23-2005 04:10 PM
Dynamically inserting a new row causes viewstate loading error on postback SoftLion ASP .Net Datagrid Control 0 05-24-2004 09:17 AM



Advertisments