Javascript中的值怎么传递到ASP中?

Javascript中的值怎么传递到ASP中?
---------------------------------------------------------------

通过表单来传递,

1<form action="process.asp" id="myform" method="post">
2<input name="jsvar" type="hidden"/>
3</form>
1<script>   
2int i;   
3i = 66;   
4myform.jsvar.value = i;   
5myform.submit;   
6</script>

'process.asp:
dim i
i = Request("jsvar")
---------------------------------------------------------------

用提交的方式可以传递到ASP中

1<script>   
2a="bbb"   
3window.location.href="index.asp?tt="+a;   
4</script>

这样index.asp就可以获得JavaScript中a变量的内容了 .
---------------------------------------------------------------

这也是个办法.可是当还有表单要提交就不行了.

1<input name="B3" onclick="myfunction" type="button" value="按钮"/>

然后在Script中定义myfunction,中间放入window.location.href="index.asp?tt="+a;和myform.submit就行了
---------------------------------------------------------------

提交form或者url傳遞

Published At
Categories with Web编程
Tagged with
comments powered by Disqus