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 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Apr 2004
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Click on row and check the checkbox

    Hi there
    I have a form which dynamicly creating with php. Because of that every checkbox name is same like name='ids[]'
    Is it possible to check the checkbox when I click on the row which contains the checkbox... I m giving you the html form code below

    <table width="90%" align="center" bgcolor="#FFDBB7" cellpadding="2" cellspacing="0" class="line">
    <form name=rlist method=POST action=/NUMUNE/hasta_rapor.php?i=rprdty&TUP_ID=FORM>
    <tr class=kalin align="LEFT" bgcolor="#F2F2F2" height=30>
    <td class=line_left2 valign=middle >
    <span class=yazi1>&nbsp;MYTABLE</span></td>
    <td class=line_left2 valign=middle >&nbsp;</td>
    <td class=line_right2 colspan=5 align=right>Tüm Testleri Göstermektedir.
    </td>
    </tr>
    <tr class=kalin align="center">
    <td class=line_top>Laba Teslim Tarihi </td>
    <td colspan="6" class=line_top>Durum
    <input type=checkbox value=" + " onClick="this.value=check(this.form.rbox)" class="checkall"> &nbsp; </td>
    </tr><tr align="center" bgcolor='#FFE8DD' onmouseover="this.style.backgroundColor='#F2F2F2';" onMouseout="this.style.backgroundColor='#FFE8DD';"onDblclick="location.href='?i=rprdty&TUP_ID=186402 4&F_TYPE=rp';" >
    <td align=left nowrap>DATA 1 </td>
    <td colspan="6" class=line_left> <input name='idler[]' id='rbox' type=checkbox value='1864024' class=chckbox1>
    </td>
    </tr><tr align="center" bgcolor='#FFDBB7' onmouseover="this.style.backgroundColor='#F2F2F2';" onMouseout="this.style.backgroundColor='#FFDBB7';"onDblclick="location.href='?i=rprdty&TUP_ID=186761 7&F_TYPE=rp';" >
    <td align=left nowrap>DATA 2 </td>
    <td colspan="6" class=line_left> <input name='idler[]' id='rbox' type=checkbox value='1867617' class=chckbox1>
    </td>
    </tr>
    <tr bgcolor=#F2F2F2 align=CENTER>
    <td colspan=8 class=line_bottom><a href='javascript:document.rlist.submit();'>Click To Submit</a></td>
    </tr></form></table>


    As you see here I have a table. I am changing row color when mouse over on it. I also want to check the checkbox when I click on it.
    So If I can do this I won' t need
    onDblclick="location.href='?i=rprdty&TUP_ID=1867617&F_TYPE=rp';
    code anymore to submit...

    Thanx To Everyone whoever replied...

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    here's an example
    PHP Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"  "http://www.w3.org/TR/html4/loose.dtd">
    <
    html>
    <
    head>
    <
    title>Untitled Document</title>
    <
    meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <
    meta http-equiv="Content-Style-Type" content="text/css">
    <
    meta http-equiv="Content-Script-Type" content="text/javascript">
    <
    script type="text/JavaScript">
    onload = function(){
    var 
    oCells document.getElementById('tab').getElementsByTagName('td');//cells' collection
    for(var i=0;i<oCells.length;i++){
    var 
    kids oCells[i].childNodes;//childNodes collection of each cell
        
    for(var j=0;j<kids.length;j++){
            if((
    kids[j].nodeType==1)&&(kids[j].getAttribute('type')=='checkbox')){//if childNode is a tag and if the type is checkbox
            
    oCells[i].onclick=function(){//sets the event handler
            
    if(this.getElementsByTagName('input')[0].checked==false){//switches checked/unchecked
            
    this.getElementsByTagName('input')[0].checked=true;
            }
            else{
            
    this.getElementsByTagName('input')[0].checked=false;
            }
            }
            }
        }
    }
    }
    </script>
    </head>
    <body>
    <table id="tab" width="300" border="1" cellpadding="2" cellspacing="2" bgcolor="#CCCCCC">
    <tr>
    <td><input type="checkbox" name="checkbox"></td>
    </tr>
    <tr>
    <td><input type="checkbox" name="checkbox"></td>
    </tr>
    <tr>
    <td><input type="checkbox" name="checkbox"></td>
    </tr>
    </table>

    </body>
    </html> 
    Last edited by Kor; 04-21-2005 at 05:34 PM.
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


  •  

    Posting Permissions

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