0
愚蠢的小脚本在我添加2个复选框后无法正常工作。 目标是用一些动态参数打开一个URL。 我用Google搜索以查找可能的错误,但我没有找到。根据请求在脚本之前声明DOM属性。javascript复选框document.getElementById返回null
有什么想法吗?谢谢
<body>
<table border="0">
<tr>
<td>Serial Number</td>
<td><input type="text" id="deviceUdid" value="251528003720" maxlength="12" size="10"></td>
</tr>
<tr>
<td>HouseHold</td>
<td><input type="checkbox" id="Household" value="1"></tr>
<tr>
<td>Community</td>
<td><input type="checkbox" id="Communities"></tr>
<tr>
<td><input type="button" id="btn" value="Submit" onClick="form_submit()"></tr>
</table>
<script type="text/javascript">
function form_submit() {
var a = 'https://test?';
a += 'ACTION=authenticateUniqueDevice';
a += '&deviceUdid=' + document.getElementById('deviceUdid').value;
a += '&CONTENT_READ_KEY=dddddddddd';
if (document.getElementById('HouseHold').checked) a += '&includeHousehold=true';
if (document.getElementById('Communities').checked) a += '&includeHouseholdCommunities=true';
window.open(a, 'MyWindow', 'width=600,height=700');
}
</script>
并不完美......所以它是如何工作的,你怎么弄?你能指望什么? –
HouseHold!==家庭 –
开发者工具控制台日志将识别这个错字 –