当我调用更新函数时,我试图获取表单上字段的值。
function update(gId, name, status){
alert(gId);
alert(name);
alert(status); \\Works fine and displays the proper element name.
alert(document.Form.status.value);\\Try to get the value of that element and it returns undefined.
}
gId,名称和状态都是传递给更新功能的元素ID的所有字符串。我有3个动态创建的输入字段,可以更新。例如:i_name,i_status,i_gid,其中我可以是0或更多。因此,当我调用此更新时,我真的传递了一个字符串,如0_gid,0_name,0_status或999_gId,999_name,999_status..ect。
伪表格代码。
<form>
input id&name=3_gId
input id&name=3_name
input id&name=3_status
Update(3_gId, 3_name, 3_status)
input id&name=11_gId
input id&name=11_name
input id&name=11_status
Update(11_gId, 11_name, 11_status)
</form>
感谢您的帮助。
答案 0 :(得分:1)
尝试做...
var text = document.getElementById(status).value;
alert(text);
或只是将document.getElementById(status).value
放入警报