...

View Full Version : Click on row and check the checkbox



jayhoonova
04-21-2005, 03:50 PM
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=1864024&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=1867617&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...

Kor
04-21-2005, 04:25 PM
here's an example


<!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>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum