怎样把数据追加到网页上?
以下怎么实现,代码是????
a.html上有个表单.
姓名:
年龄:
班级:
点击提交,提交到1.html
1.html接收到数据后经处理,把数据以表格的形式追加到2.html上。如:
姓名 年龄 班级
aa 20 01
bb 20 02
cc 20 01
------解决方案--------------------哈哈,终于写完了,我也是刚学javascript的
这个是我写的第一个代码,一遍翻书,一遍查错搞了近一个小时才出来
看在我这么辛苦的份上多给点分吧
<html>
<head>
</head>
<body>
<script language= "javascript " type= "text/javascript ">
var JiLu=new Array()
function TongXunLu(XingMing,NianNing,BanJi)
{
this.XingMing=XingMing;
this.NianNing=NianNing;
this.BanJi=BanJi;
}
function Jia(XingMing,NianNing,BanJi)
{
if(XingMing== " " || NianNing== " " || BanJi== " ")
{
alert( "请把信息填写完 ");
return;
}
var Linshi= new TongXunLu();
Linshi.XingMing=XingMing;
Linshi.NianNing=NianNing;
Linshi.BanJi=BanJi;
JiLu.push(Linshi);
}
function Show()
{
newWin = open( ' ', ' ', 'height=300,width=400 ');
with (newWin.document) {
write( "共有 "+JiLu.length+ "条数据 ");
write( " <table> ");
write( " <tr> <td> 姓名 </td> <td> 年龄 </td> <td> 班级 </td> </tr> ");
for (var j=0;j <JiLu.length;j++) {
write( " <tr> <td> ",JiLu[j].XingMing, " </td> ");
write( " <td> ",JiLu[j].NianNing, " </td> ");
write( " <td> ",JiLu[j].BanJi, " </td> </tr> ");
}
write( " </table> ");
}
}
</script>
姓名:
<input id= "XM " value= " " type= "text "> <br>
年龄:
<input id= "NN " value= " " type= "text "> <br>
班级:
<input id= "BJ " value= " " type= "text "> <br>
<input name= "JiaRu " id= "JiaRu " value= "加入通讯薄 " type= "button " onclick= "Jia(XM.value,NN.value,BJ.value) ">
<input name= "AllXianshi " id= "AllXianshi " type= "button " value= "显示所有数据 " onclick= "Show() ">
</body>
</html>