plz check this:<script language="javascript">
function add(no)
{
var fom=document.forms[no];
var a=fom.a.value;
alert(a);
}
</script>//以下是一个循环里的form
<form name="form1" method="post" action="">
<input name="a" type="text" size="10" value="this is a1">
<input type="button" name="Submit" value="按钮" onclick="add(0)">
</form>
<form name="form2" method="post" action="">
<input name="a" type="text" size="10" value="this is a2">
<input type="button" name="Submit" value="按钮" onclick="add(1)">
</form>
function add(no)
{
var fom=document.forms[no];
var a=fom.a.value;
alert(a);
}
</script>//以下是一个循环里的form
<form name="form1" method="post" action="">
<input name="a" type="text" size="10" value="this is a1">
<input type="button" name="Submit" value="按钮" onclick="add(0)">
</form>
<form name="form2" method="post" action="">
<input name="a" type="text" size="10" value="this is a2">
<input type="button" name="Submit" value="按钮" onclick="add(1)">
</form>
我把form放在一个循环里,不能直接用数值的,只能用个变量来代替啊...
<?php
$i = 1;
while ($i <= 10):
?>
<form name="form<?=$i;?>" method="post" action="">
...
</form>
<?
endwhile;
?>
var fom = eval("document.forms["+no+"]");