Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Aug 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Accessing controls inside a table

    Hi,

    I have a table on which there are a number of cells. some cells contain input boxes that allow users to enter various information. However I need to know how to access the information contained within each cell to allow me to compare it to some other information. Would anyone be able to tell me if this is possible and how I would go about it.

    Thanks in advance
    Kenny

  • #2
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,534
    Thanks
    3
    Thanked 512 Times in 499 Posts
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
    
    <html>
    
    <head>
      <title></title>
    <script language="JavaScript" type="text/javascript">
    <!--
    
    function zxcFndCell(){
     var zxcevt=window.event||arguments.callee.caller.arguments[0];
     var zxcobj=zxcEventObj(zxcevt);
     while (zxcobj.parentNode){
      if (zxcobj.tagName=='TD'){ break; }
      zxcobj=zxcobj.parentNode;
     }
     var zxcips=zxcobj.getElementsByTagName('INPUT');
     for (var zxc0=0;zxc0<zxcips.length;zxc0++){
      if (zxcips[zxc0].type=='text'){
       alert(zxcips[zxc0].value);
      }
     }
    
    }
    
    function zxcEventObj(zxce){
     if (!zxce) var zxce=window.event;
     zxce.cancelBubble=true;
     if (zxce.stopPropagation) zxce.stopPropagation();
     if (zxce.target) zxceobj=zxce.target;
     else if (zxce.srcElement) zxceobj=zxce.srcElement;
     if (zxceobj.nodeType==3) zxceobj=zxceobj.parentNode;
     return zxceobj;
    }
    
    
    
    //-->
    </script>
    
    </head>
    
    <body>
    <table border="1" onclick="zxcFndCell();">
      <tr>
        <td><input name="" value="123" ></td>
        <td><input name="" value="1234" ></td>
      </tr>
      <tr>
        <td><input name="" value="12345" ></td>
        <td><input name="" value="123456" ></td>
      </tr>
    </table>
    </body>
    
    </html>
    Vic

    God Loves You and will never love you less.

    http://www.vicsjavascripts.org/Home.htm

    If my post has been useful please donate to http://www.operationsmile.org.uk/

  • #3
    New to the CF scene
    Join Date
    Aug 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thank you

    cheers!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •