前几天写了篇"静态页面也玩参数",客户端脚本是完全可以获取地址中的参数及其值的,那么有没有办法让表单的值在地址上进行传送,问题解决了,将表单的POST方法改为Get方法即可。
以前一直就想既然POST方法比Get方法更为安全,那为什么还要存在Get这个方法呢?今天看来,存在的就有其存在道理的,呵呵。
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title> 客户端脚本获取表单传值</title>
</head>
<body>
<form id="form1" name="form1" method="get" action="">
<input type="text" name="textfield" />
<input type="text" name="textfield2" />
<input type="submit" name="Submit" value="提交" />
</form>
<script language="VBScript">
Sub getPra()
Dim url,i,j,n,arr()
n = 0
j = 0
url = document.location.href
For i = 1 to len(url)
If mid(url,i,1) = "=" then n = n + 1
Next
n = n * 2
ReDim arr(n)
For i = 1 to len(url)
If mid(url,i,1) = "=" then
arr(j) = i
j = j + 1
End if
If mid(url,i,1) = "&" then
arr(j) = i
j = j + 1
End if
If mid(url,i,1) = "?" then
arr(j) = i
j = j + 1
End if
Next
arr(n) = len(url) + 1
j = 1
For i = 0 to n-1 step 2
Document.write "第" & j & "个参数:" & mid(url,arr(i)+1,arr(i+1)-arr(i)-1) & "=" & mid(url,arr(i+1)+1,arr(i+2)-arr(i+1)-1) & "<br>"
j = j + 1
Next
End sub
Call getPra()
</script>
</body>
</html>
评论(0)
暂无评论。