日期:2014-05-16  浏览次数:20440 次

如何使用Javascript实现对表单中指定数据的提交?
<form id="loginform" name="loginformName" action="./pass.php?do=login" method="post" >
<div class="placeholder">邮箱或昵称</div>
<input class="ipt iptlong" type="text" value="" name="account" >
<div class="placeholder">密码</div>
<input class="ipt" type="password" value="" name="password">
<input type="button" value=""  onclick="submit();">
</form>
想只提交用户名,不提交密码
submit()函数怎么写?
------解决方案--------------------
form表单去掉
改用ajax提交
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
function submit(){
         $.post("./pass.php?do=login", { name: "John"} );
 }

------解决方案--------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
function submits(){
var form=document.getElementById('loginform');
var eles=form.elements;
for(var i=0,len=eles.length;i<len;i++){
if(eles[i].getAttribute('not_submit')=='true'){
eles[i].disabled=true;
}
}
form.submit();
}
</script>
</head>

<body>
<form id="loginform" name="loginformName" action="http://www.baidu.com" method="post" >
<div class="placeholder">邮箱或昵称</div>
<input class="ipt iptlong" type="text" value="" name="account" >
<div class="placeholder">密码</div>
<input class="ipt" type="password" value="" name="password" not_submit='true'>
<input type="button" value=""  onclick="submits();">
</form>
</body>
</html>

类似这样试试