PDA

View Full Version : how do I refer two forms to the same function?



golmiami
06-02-2008, 02:20 AM
This function brings up the only raws selected when I click compare. The problem is that I have the same form twice. How can solve this?


<html>

<head>
<script type="text/javascript">
<!--
window.onload=function()
{
document.getElementById('onclick').onclick=function()
{
var check=document.getElementsByTagName('input'),
divs=document.getElementsByTagName('tr'),i=0;
for(var i;i<check.length,i<divs.length;i++)
{
divs[i].style.display='none';
if(check[i].type=='checkbox')
{
if(check[i].checked==true)
divs[i].style.display='';
}}}}
//-->
</script>
</head>

<body>

<form><label></label><label></label>
<table width="953" border="1">
<tr id="dd1">
<td width="829" >1</td>
<td width="108" ><input type="checkbox" name="modtype2" value="value1" />
<label>value1</label></td>
</tr>
<tr id="dd2">
<td >2</td>
<td ><input type="checkbox" name="modtype3" value="value2" />
<label>value2</label></td>
</tr>
<tr id="dd3">
<td >3</td>
<td ><input type="checkbox" name="modtype4" value="value3" />
<label>value3</label></td>
</tr>
<tr id="dd4">
<td >4</td>
<td ><input type="checkbox" name="modtype5" value="value4" />
<label>value4</label></td>
</tr>
<tr id="dd5">
<td >5</td>
<td ><input type="checkbox" name="modtype" value="value5" />
<label>value5</label></td>
</tr>
</table>


<br>
<input type="button" name="onclick" id="onclick" value="Compare">
<br>
</form>

<form><label></label><label></label>
<table width="953" border="1">
<tr id="dd1">
<td width="829" >1</td>
<td width="108" ><input type="checkbox" name="modtype2" value="value1" />
<label>value1</label></td>
</tr>
<tr id="dd2">
<td >2</td>
<td ><input type="checkbox" name="modtype3" value="value2" />
<label>value2</label></td>
</tr>
<tr id="dd3">
<td >3</td>
<td ><input type="checkbox" name="modtype4" value="value3" />
<label>value3</label></td>
</tr>
<tr id="dd4">
<td >4</td>
<td ><input type="checkbox" name="modtype5" value="value4" />
<label>value4</label></td>
</tr>
<tr id="dd5">
<td >5</td>
<td ><input type="checkbox" name="modtype" value="value5" />
<label>value5</label></td>
</tr>
</table>


<br>
<input type="button" name="onclick" id="onclick" value="Compare">
<br>
</form>



</body>
</html>

jscheuer1
06-02-2008, 03:19 AM
I just answered this here:

http://www.dynamicdrive.com/forums/showthread.php?p=146134#post146134

Please post only one post per question.