【发布时间】:2013-05-04 16:10:25
【问题描述】:
我有一个无法更改输入值字段名称的表单。 一个这样的字段在 HTML 中如下所示:
<body>
<form id="f" method="get" action="/code/submit.php">
<input type="text" name="var[list]" id="ixv[list]" value="">
<button type="button" title="Save" onclick="check();">
</form>
</body>
现在在我的 javascript 中,我想访问该输入值。 我试过这个,当然它不起作用,因为 [] 看起来 就像 JS 中的数组一样。
function check() {
var x=var[list].value;
alert(x);
}
问题是变量名中有[]。我怎样才能得到 javascript中的输入字段值?
【问题讨论】:
标签: javascript html forms variables input