使用onchange在第二个字段javascript中输入数据
我试图把两个表单放在一个页面上,但只有一个主显示区可以进行选择。我的页面看起来像这样: 序列ID---选择处理器---选择审阅者 1------------------A------------------B------------------操作按钮 2------------------A------------------B------------------动作按钮 3------------------A------------------B------------------动作按钮 其中A和B是淹没列表,用户可以选择 然后,在页面的单独部分中,以单独的形式,将在单独的文本字段中填充上面选择的a和B。问题在于这两种形式的处理方式。上面的“操作按钮”根本不使用A和B下拉信息。但是为了使显示更加简洁,我不想让用户滚动到页面的各个部分以执行不同的操作。太令人困惑了 这是踢球的人。序列中的总数将根据表格的不同而不同。因此,我需要为字段创建一个数组。我知道这没有多大意义,所以我这里是我的代码:使用onchange在第二个字段javascript中输入数据,javascript,arrays,onchange,Javascript,Arrays,Onchange,我试图把两个表单放在一个页面上,但只有一个主显示区可以进行选择。我的页面看起来像这样: 序列ID---选择处理器---选择审阅者 1------------------A------------------B------------------操作按钮 2------------------A------------------B------------------动作按钮 3------------------A------------------B------------------动作按钮
<script type="text/javascript">
function myFunction() {
document.proc[1].value = f.processor[1].value;
document.write.getElementById("proc[1]").value;
document.rev[1].value = f.reviewer[1].value;
document.write.getElementById("rev[1]").value;
document.proc[2].value = f.processor[2].value;
document.write.getElementById("proc[2]").value;
document.rev[2].value = f.reviewer[2].value;
document.write.getElementById("rev[2]").value;
document.proc[3].value = f.processor[3].value;
document.write.getElementById("proc[3]").value;
document.rev[3].value = f.reviewer[3].value;
document.write.getElementById("rev[3]").value;
}
</script>
<form id="form" action="thispage.php" method="post">
<select name="processor[1]" onchange="myFunction(this.document)" id="processor[1]">
<option value="0">--Please select from the list...</option>
<option value="A">A</option>
<option value="B">B</option>
<option value="C">C</option>
</select>
<select name="reviewer[1]" onchange="myFunction(this.document)" id="reviewer[1]">
<option value="0">--Please select from the list...</option>
<option value="A">A</option>
<option value="B">B</option>
<option value="C">C</option>
</select>
<select name="processor[2]" onchange="myFunction(this.document)" id="processor[2]">
<option value="0">--Please select from the list...</option>
<option value="A">A</option>
<option value="B">B</option>
<option value="C">C</option>
</select>
<select name="reviewer[2]" onchange="myFunction(this.document)" id="reviewer[2]">
<option value="0">--Please select from the list...</option>
<option value="A">A</option>
<option value="B">B</option>
<option value="C">C</option>
</select>
<select name="processor[3" onchange="myFunction(this.document)" id="processor[3]">
<option value="0">--Please select from the list...</option>
<option value="A">A</option>
<option value="B">B</option>
<option value="C">C</option>
</select>
<select name="reviewer[3]" onchange="myFunction(this.document)" id="reviewer[3]">
<option value="0">--Please select from the list...</option>
<option value="A">A</option>
<option value="B">B</option>
<option value="C">C</option>
</select>
<input type="submit" name="action" value="Action Button">
</form>
<form id="newForm" action="thisform.php" method="post">
<input type="text" name="proc[1]" id="proc[1]">
<input type="text" name="rev[1]" id="rev[1]">
<input type="text" name="proc[2]" id="proc[2]">
<input type="text" name="rev[2]" id="rev[2]">
<input type="text" name="proc[3]" id="proc[3]">
<input type="text" name="rev[3]" id="rev[3]">
</form>
函数myFunction(){
document.proc[1]。value=f.processor[1]。value;
document.write.getElementById(“proc[1]”)的.value;
document.rev[1]。value=f.reviewer[1]。value;
document.write.getElementById(“rev[1]”)值;
document.proc[2]。value=f.processor[2]。value;
document.write.getElementById(“proc[2]”)的.value;
document.rev[2]。value=f.reviewer[2]。value;
document.write.getElementById(“rev[2]”)值;
document.proc[3]。value=f.processor[3]。value;
document.write.getElementById(“proc[3]”)的.value;
document.rev[3]。value=f.reviewer[3]。value;
document.write.getElementById(“rev[3]”)值;
}
--请从列表中选择。。。
A.
B
C
--请从列表中选择。。。
A.
B
C
--请从列表中选择。。。
A.
B
C
--请从列表中选择。。。
A.
B
C
--请从列表中选择。。。
A.
B
C
--请从列表中选择。。。
A.
B
C
当我进行选择时,数据不会输入到newForm中的文本字段中,这正是我希望发生的
任何人如能提供任何建议,我们将不胜感激。请回答选择未被转移的原因: 拥有
不允许您通过document.proc[1]
引用它。文档对象模型并没有那么神奇
其他说明:
此代码还有许多其他问题,例如
this.document
和document.write.getElementById(…).value
。您可能应该花一些时间学习JavaScript和文档对象模型,并找到适合此应用程序的方法。感谢您花时间查看代码。我知道我是JavaScript的新手。我会进一步研究。