当我尝试执行以下Javascript时,我在IE11中收到未定义的错误:alert('obj: ' + document.payment_method.elements['285_id[35]']);
非数组表示法表单名称似乎工作正常。这里有一些js小提琴测试:http://jsfiddle.net/o2d2c16r/2/
<html>
<head>
</head>
<body>
<form name="payment_method">
<select name="285_id[35]">
<option value="1">value 1</option>
<option value="2">value 2</option>
<option value="3">value 3</option>
<option value="4">value 4</option>
</select>
<input type="text" name="mytext" value="text entered" />
<select name="myselect">
<option value="a">value a</option>
<option value="b">value b</option>
<option value="c">value c</option>
<option value="d">value d</option>
</select>
</form>
<script>
alert('obj: ' + document.payment_method.elements['285_id[35]']);
alert('obj: ' + document.payment_method.elements['mytext']);
alert('obj: ' + document.payment_method.elements['myselect']);
alert('obj length: ' + document.payment_method.elements['myselect'].length);
</script>
</body>
</html>
任何帮助将不胜感激! 谢谢,
甘