javascript中 如何将表单中输入的数据提交到表格中去?
<html><head><scripttype="text/javascript">functiondoSubmit(){varuserName=document.get...
<html>
<head>
<script type="text/javascript">
function doSubmit(){
var userName=document.getElementById("userName").value;
var userPass=document.getElementById("userPass").value;
}
</script>
</head>
<body>
<table border="1" width="500" align="center">
<thead >
<tr>
<td>账号</td><td>密码</td><td>地址</td>
</tr>
</thead>
<tbody>
<tr>
<td></td>
</tr>
</tbody>
<tfoot>
</tfoot>
</table>
<hr color="red">
<form onsubmit="return doSubmit()">
userName:<input type="text" id="userName">
<br />
userPass:<input type="password" id="userPass">
<br />
<input type="submit" value="提交">
</form>
</body>
</html>
我进行到这步就进行不下去了,不知道用什么方法可以讲userName和userPass中输入的数据传到thead表格中去,请高手来帮一下忙!
本人初学,希望尽量详细点,最好在这段代码的基础上加以完成,谢谢! 展开
<head>
<script type="text/javascript">
function doSubmit(){
var userName=document.getElementById("userName").value;
var userPass=document.getElementById("userPass").value;
}
</script>
</head>
<body>
<table border="1" width="500" align="center">
<thead >
<tr>
<td>账号</td><td>密码</td><td>地址</td>
</tr>
</thead>
<tbody>
<tr>
<td></td>
</tr>
</tbody>
<tfoot>
</tfoot>
</table>
<hr color="red">
<form onsubmit="return doSubmit()">
userName:<input type="text" id="userName">
<br />
userPass:<input type="password" id="userPass">
<br />
<input type="submit" value="提交">
</form>
</body>
</html>
我进行到这步就进行不下去了,不知道用什么方法可以讲userName和userPass中输入的数据传到thead表格中去,请高手来帮一下忙!
本人初学,希望尽量详细点,最好在这段代码的基础上加以完成,谢谢! 展开
展开全部
<html>
<head>
<script type="text/javascript">
function doSubmit(){
var userName=document.getElementById("userName").value;
var userPass=document.getElementById("userPass").value;
document.getElementById("user").innerHTML=":"+userName;
document.getElementById("psd").innerHTML=":"+userPass;
return false;
}
</script>
</head>
<body>
<table border="1" width="500" align="center">
<thead >
<tr>
<td>账号<span id='user'></span></td><td>密码<span id='psd'></span></td><td>地址</td>
</tr>
</thead>
<tbody>
<tr>
<td></td>
</tr>
</tbody>
<tfoot>
</tfoot>
</table>
<hr color="red">
<form onsubmit="return doSubmit()">
userName:<input type="text" id="userName">
<br />
userPass:<input type="password" id="userPass">
<br />
<input type="submit" value="提交">
</form>
</body>
</html>
<head>
<script type="text/javascript">
function doSubmit(){
var userName=document.getElementById("userName").value;
var userPass=document.getElementById("userPass").value;
document.getElementById("user").innerHTML=":"+userName;
document.getElementById("psd").innerHTML=":"+userPass;
return false;
}
</script>
</head>
<body>
<table border="1" width="500" align="center">
<thead >
<tr>
<td>账号<span id='user'></span></td><td>密码<span id='psd'></span></td><td>地址</td>
</tr>
</thead>
<tbody>
<tr>
<td></td>
</tr>
</tbody>
<tfoot>
</tfoot>
</table>
<hr color="red">
<form onsubmit="return doSubmit()">
userName:<input type="text" id="userName">
<br />
userPass:<input type="password" id="userPass">
<br />
<input type="submit" value="提交">
</form>
</body>
</html>
追问
谢谢!
如何在 中每输入一组数据,就自动创建一行新的表格,并将数据提交到该行对应的单元格内 ?这才是我的本意,嘿嘿!
追答
function doSubmit(){
var userName=document.getElementById("userName").value;
var userPass=document.getElementById("userPass").value;
row = document.getElementById("TableA").insertRow();
if(row!=null){
cell=row.insertCell();
cell.innerHTML=userName;
cell = row.insertCell();
cell.innerHTML=userPass;
cell = row.insertCell();
cell.innerHTML=" ";
}
return false;
}
账号密码地址
userName:
userPass:
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询