日期:2014-05-17  浏览次数:20691 次

表单多个按钮提交

我想点击不同按钮,删除或修改不同用户

------解决方案--------------------
1.每一行用户的修改都相应的对应一行的用户id。
2.在修改和删除的时候,根绝用户id来判断要修改的用户。



------解决方案--------------------
必须要有id的
------解决方案--------------------
function butn(val){
var valua=document.getElementById(val).value;
alert(valua);
}
</script>
 <BODY>
   <input type="text" id="t1"> <input type="button" onclick="butn('t1')"></br>
   <input type="text" id="t2"> <input type="button" onclick="butn('t2')"></br>
   <input type="text" id="t3"> <input type="button" onclick="butn('t3')">
 </BODY>
</HTML>

------解决方案--------------------
<script type="text/javascript">
//删除
function delete(id){
var username=document.getElementsByName("username")[id].value;
var password=document.getElementsByName("password")[id].value;
var actions="tiJiao.do?usernames="+username+"&passwords="+password;
document.mainForm.action=actions;
document.mainForm.submit();

//修改
function modify(id){

}
这上面的差不多
</script>

<body>
<form name="mainForm" action="" method="">
用户名:<input type="text" name="username" />
密码:<input type="password" name="password" />
<input type="submit" value="修改密码" onclick="modify(0)" />
<input type="submit" value="修改" onclick="delete(0)" /><br />
用户名:<input type="text" name="username" />
密码:<input type="password" name="password" />
<input type="submit" value="修改密码" onclick="modify(1)" />
<input type="submit" value="修改" onclick="delete(1)" />
用户名:<input type="text" name="username" />
密码:<input type="password" name="password" />
<input type="submit" value="修改密码" onclick="modify(2)" />
<input type="submit" value="修改" onclick="delete(2)" />
</form>
</body>