环境IE8
<html>
<head>
<title>JS</title>
<script type="text/javascript">
function test(){
alert(document.getElementsByName("fpdm")[0].value)
}
</script>
</head>
<body>
<form name="form1">
<input type="text" name="fpdm">
<input type="text" name="fpdm">
</form>
<input type="button" onclick="test()" value="Click">
</body>
</html>
(1)
function test(){
alert(document.form1.fpdm.value)
}
报错:undefined;
同一个表单多个同名的就报错,不会自动取第一个对象。
(2)
function test(){
alert(document.getElementsByName("fpdm")[0].value)
}
ok
分享到:
相关推荐
2. **避免与API重名**:在定义ID、类名或变量名时,最好避免与JavaScript或DOM API中的保留关键字和属性名称相同,以减少潜在问题。 总结: 在进行Web开发时,遵循良好的编程和命名规范至关重要。对于表单提交,...
document.getElementById('progressBar').value = progress; }; xhr.onloadstart = function() { document.getElementById('progressBar').value = 0; }; xhr.onloadend = function() { document....
varddl=oEditor.parent.document.Form1.ddlPicUrl; varopt=oEditor.parent.document.createElement("OPTION") opt.text=fileName; opt.value=fileUrl ddl.options.add(opt); ``` - 其中,`oEditor`是对网页...
document.getElementById('progressBar').value = Math.round(percent); }, false); xhr.onload = function() { alert(xhr.responseText); }; xhr.send(formData); } ``` 在这个例子中,当用户点击“上传...
<property name="maxUploadSize" value="10485760"/> <!-- 10MB --> ``` 接下来,我们创建一个Controller来处理文件上传请求。在Controller类中,定义一个方法,使用`@RequestParam("file") MultipartFile file`...
formData.append("myfile", document.getElementById("file1").files[0]); $.ajax({ url: "/Home/index/fileupsend", type: "POST", data: formData, contentType: false, processData: false, success: ...