-
Sep 20th, 2006, 03:40 PM
#1
Thread Starter
Frenzied Member
[resolved][Javascript] Find datagrid <input> text element values for only one column
I have a datagrid on an asp.net page and I need to find the values in embedded <input> text element controls only for a certain column in order to sum these values.
This javascript only gets me down to the <td>'s I need and I can't go any further to get to the <input>'s and get the values. Not all cells in this column have embedded <input> elements.
PHP Code:
function GetValues()
{
// get datagrid by rendered table name
var grid = document.getElementById('datagrid1');
var len = grid.rows.length;
// touch each row, retrieve cell 2 innerHTML
for(i = 0; i < len; i++)
{
// show raw text for cells, <input type="text"... > for text box
alert(grid.rows[i].cells[2].innerHTML);
}
}
How can I get the values of the <input> text elements?
Last edited by wey97; Sep 26th, 2006 at 07:26 AM.
-
Sep 21st, 2006, 04:44 AM
#2
Re: Find datagrid <input> text element values for only one column [Javascript]
Untested and been a while again since I touched JavaScript, but here's a try:
PHP Code:
// in the loop
var inputelements = grid.rows[i].cells[2].getElementsByTagName('input');
var maxj = inputelements.length;
for(j = 0; j < maxj; j++)
{
if(inputelements[j].getAttribute('type') == 'text') {
alert(inputelements[j].getAttribute('value'));
}
}
-
Sep 21st, 2006, 09:06 AM
#3
Thread Starter
Frenzied Member
Re: Find datagrid <input> text element values for only one column [Javascript]
-
Jan 13th, 2009, 07:18 AM
#4
New Member
Re: [resolved][Javascript] Find datagrid <input> text element values for only one column
Fantastic. I've been looking for a solution to this for a couple of weeks now. My javascript has become a bit rusty but this works perfectly. So a huge thank you.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|