[resolved][Javascript] Find datagrid <input> text element values for only one column-VBForums
Results 1 to 4 of 4

Thread: [resolved][Javascript] Find datagrid <input> text element values for only one column

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Location
    Birmingham, AL
    Posts
    1,276

    Resolved [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(0leni++)
        {
            
    // 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.

  2. #2
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    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(
    0maxjj++)
        {
            if(
    inputelements[j].getAttribute('type') == 'text') {
                
    alert(inputelements[j].getAttribute('value'));
            }
        } 

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Location
    Birmingham, AL
    Posts
    1,276

    Re: Find datagrid <input> text element values for only one column [Javascript]

    Perfect.

  4. #4
    New Member
    Join Date
    Jan 2009
    Posts
    1

    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
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.