This Domain(Admin5.com) is for Sale:

javascript表单之间的数据传递

时间:2007-10-22  来源:不详  作者:林子
今天有朋友问我关于用JAVASCRIPT来进行页面各表单之间的数据传递的问题,我以前也写过,不过从来没有注意,今天总结了一下,希望能够给大家一些帮助,也帮助我总结以前学过,用过的知识。

一,最简单的就是同一个网页里的表单的数据传递。 copyright dedecms

举个实例,一个网页上有两个表单,每个表单里一个文本框,一个按钮。点按钮互相对操作对方的文本框的值。我们举的例子是把一个文本框付给另一个文本框。具体的HTML代码如下:

copyright dedecms

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body> copyright dedecms

<form name="form1" method="post" action="">
<input type="text" name="textfield">
<input type="button" name="Submit" value="1---------&gt;2" onClick="ok()">
</form> 织梦内容管理系统

<form name="form2" method="post" action="">
<input type="text" name="textfield2">
<input type="button" name="Submit" value="2-----&gt;1" onClick="ok1()">
</form>

dedecms.com

</body>
</html>

以上为HTMl的代码,大家可能注意到了onclik的代码了,有两个函数,接下来就是JAVASCRIPT的代码了: 织梦内容管理系统

<script language="JavaScript">
function ok()
{
document.form2.textfield2.value=document.form1.textfield.value;
}
function ok1()
{
document.form1.textfield.value=document.form2.textfield2.value;
}
</script>

织梦内容管理系统

转自:动态网制作指南 www.knowsky.com

看完这篇,您有何感觉呢?

文章评论

共有位Admini5网友发表了评论 查看完整内容

24小时热门信息