HighTechTalks DotNet Forums  

How to get textBox object

Dotnet Scripting microsoft.public.dotnet.scripting


Discuss How to get textBox object in the Dotnet Scripting forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
 
Posts: n/a

Default How to get textBox object - 01-28-2005 , 10:23 PM






I use JavaScript to insert Row with textbox into table on
client script. When i entered value into dynamic textbox,
i could get textbox object using getElementById.
Code is below how row was added.
function addRowToTable()
{
var tbl = document.getElementById('tblSample');
var lastRow = tbl.rows.length;
// if there's no header row in the table, then
iteration = lastRow + 1
var iteration = lastRow;
var row = tbl.insertRow(lastRow);

// left cell
var cellLeft = row.insertCell(0);
var textNode = document.createTextNode(iteration);
cellLeft.appendChild(textNode);

// right cell
var cellRight = row.insertCell(1);
var el = document.createElement('input');
el.setAttribute('type', 'text');
el.setAttribute('name', 'txtRow' + iteration);
el.setAttribute('size', '40');
cellRight.appendChild(el);
}

Any help will be appr.

Reply With Quote
  #2  
Old   
bruce barker
 
Posts: n/a

Default Re: How to get textBox object - 01-31-2005 , 04:10 PM






you did not add an id attibute. add the id or use getElementsByName().

-- bruce (sqlwork.com)



<anonymous (AT) discussions (DOT) microsoft.com> wrote

Quote:
I use JavaScript to insert Row with textbox into table on
client script. When i entered value into dynamic textbox,
i could get textbox object using getElementById.
Code is below how row was added.
function addRowToTable()
{
var tbl = document.getElementById('tblSample');
var lastRow = tbl.rows.length;
// if there's no header row in the table, then
iteration = lastRow + 1
var iteration = lastRow;
var row = tbl.insertRow(lastRow);

// left cell
var cellLeft = row.insertCell(0);
var textNode = document.createTextNode(iteration);
cellLeft.appendChild(textNode);

// right cell
var cellRight = row.insertCell(1);
var el = document.createElement('input');
el.setAttribute('type', 'text');
el.setAttribute('name', 'txtRow' + iteration);
el.setAttribute('size', '40');
cellRight.appendChild(el);
}

Any help will be appr.



Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.