关于从提交页面中获取变量的问题 <script language="JavaScript"><!--var j = <%=j%>;var k = <%=k%>;//--></script>这样试试看看....... 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <SCRIPT LANGUAGE="JavaScript"><!--/** * js取url参数的函数 * [email protected] */function Request(){ var srch = window.location.search; if (srch.length==0) return null; srch = srch.substring(1,srch.length-1); this.nv = srch.split("&"); this.names = new Array(); this.values = new Array(); for (var i=0;i<this.nv.length;i++){ var tmp = this.nv[i].split("=") this.names[i] = tmp[0]; this.values[i] = tmp[1]; } this.getValue = function(name){ for(var i=0;i<this.names.length;i++){ if (this.names[i] == name) return this.values[i]; break; } return null; } return this;}var curReq = new Request();alert(curReq.getValue("name"));//if (href=='url?name=gzh&id=1') return 'gzh';//--></SCRIPT> 非常感谢两位,我要的结果正是这样,随便再问一下,在提交的表单中的对象值怎么样能提出呢,不知道是否说明白,就是<form name=j mothod=post><input type=text name=password value=jj></form>这个表单提交后有一个j.password.value值不知道怎么样取出来。谢谢! 把form的mothod改为get<html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><meta name="GENERATOR" content="Microsoft FrontPage 4.0"><meta name="ProgId" content="FrontPage.Editor.Document"><title>New Page 1</title></head><body><form method="get" action="gp.html"> <!--webbot bot="SaveResults" U-File="C:\Documents and Settings\Administrator\桌面\_private\form_results.txt" S-Format="TEXT/CSV" S-Label-Fields="TRUE" --> <p><input type="text" name="name" size="20" value="good"></p> <p><input type="submit" value="提交" name="B1"><input type="reset" value="全部重写" name="B2"></p></form></body></html> 不好意思,有个错误srch = srch.substring(1,srch.length-1);-->srch = srch.substring(1,srch.length); 无法获取属性“opener”的值: 对象为 null 或未定义 【高分等待高人】JavaScript 如何判断浏览器是关闭还是刷新?兼容Firefox、IE6、IE8 帮我看看 怎么让他兼容火狐 数字和符号的验证???? javascript 中能否用汉字做为JAVASCRIPT函数的参数传递 表头的问题,怎么处理!?? 求助怎么样在前台截取value中的字段? 求一正则表达式:表示以"http://"开头的网址 那位大侠给个例子? 关于动态设置对象 怎样才能实现 关闭浏览器时调用 script, 但在刷洗时不调用. JAVASCRIPT能否读取客户端文件,在线等,高分!!!
<!--
/**
* js取url参数的函数
* [email protected]
*/
function Request(){
var srch = window.location.search;
if (srch.length==0) return null;
srch = srch.substring(1,srch.length-1);
this.nv = srch.split("&");
this.names = new Array();
this.values = new Array();
for (var i=0;i<this.nv.length;i++){
var tmp = this.nv[i].split("=")
this.names[i] = tmp[0];
this.values[i] = tmp[1];
}
this.getValue = function(name){
for(var i=0;i<this.names.length;i++){
if (this.names[i] == name) return this.values[i];
break;
}
return null;
}
return this;
}
var curReq = new Request();
alert(curReq.getValue("name"));//if (href=='url?name=gzh&id=1') return 'gzh';
//-->
</SCRIPT>
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>New Page 1</title>
</head><body><form method="get" action="gp.html">
<!--webbot bot="SaveResults"
U-File="C:\Documents and Settings\Administrator\桌面\_private\form_results.txt"
S-Format="TEXT/CSV" S-Label-Fields="TRUE" -->
<p><input type="text" name="name" size="20" value="good"></p>
<p><input type="submit" value="提交" name="B1"><input type="reset" value="全部重写" name="B2"></p>
</form></body></html>
srch = srch.substring(1,srch.length-1);
-->
srch = srch.substring(1,srch.length);