1.one page: action_demo.html
<html>
<head></head>
<body>
<form name="input" action="html_form_action.html" method="get">
Usename:
<input type="text" name="user" value="admin"><input type="submit" value="Submit">
</form>
</body>
</html>
2.two page: html_from_action.html
<html>
<head></head>
<script language="javascript">
function getparastr(strname)
{
var hrefstr,pos,parastr,para,tempstr;
hrefstr = window.location.href;
pos = hrefstr.indexOf("?")
parastr = hrefstr.substring(pos+1);
para = parastr.split("&");
tempstr="";
for(i=0;i<para.length;i++)
{
tempstr = para[i];
pos = tempstr.indexOf("=");
if(tempstr.substring(0,pos) == strname)
{
return tempstr.substring(pos+1);
}
}
return null;
}
// 获取program参数
//var userstr = getparastr("user");
//document.write(userstr);
//用得到的值给form中的文本框赋值
function getname()
{
var userstr = getparastr("user");
document.fr1.input.value=userstr;
}
</script>
<body>
<form name="fr1" >
你的名字是:
<input type="text" name="input" >
<input type="button" name="bt1" value="查看用户名" onclick="getname()">
</form>
</body>
</html>
posted on 2006-09-05 10:18
摩西 阅读(5027)
评论(1) 编辑 收藏