<form name="form1">
<input type="text" id="text1" />
<button onclick="myfunction()">输出</button></form>
<form name="form2">
<input type="text" id="text2" />
<button onclick="myfunction()">输出</button></form>
<form name="form3">
<input type="text" id="text3" />
<button onclick="myfunction()">输出</button></form>
上面这些文本框是数据库循环输出的,数量不定。
<input type="text" id="recive" />
//这个文本框只有一个,用来点按钮后接收对应文本框传的值
<script>
function myfunction()
{
document.getElementById("recive").value=document.getElementById("text1").value; //这里要怎样写才能每个文本框都运行
}
</script>
没大看懂你要干嘛,每个文本框都运行是什么意思,是要获取所点击的按钮前的文本内容吗,是的话可以这么写
还可以在onclick中把对应的文本id传过去,比如