在服务器端保存变量JavaScript变量

在服务器端保存变量JavaScript变量

本文介绍了在服务器端保存变量JavaScript变量(VBScript)的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道你不能保存的JavaScript变量直接到服务器端变量(VBScript)的,但有没有办法解决像储存Java脚本变量转换成HTML隐藏的输入,然后使用JavaScript来发布。这可能吗?如果不是我能做些什么呢?下面是我的code迄今为止获得下拉列表的值 - 的JavaScript

 函数selectedDatabase(){            select_temp = form1.elements [选择];
            select_index = select_temp.selectedIndex;
            select_text = select_temp.options [select_index]的.text;        }

下面是HTML code

 <中心及GT;<选择一个id =选择的onchange =selectedDatabase()>
<选项>影LT; /选项>
<选项>电影2'; /选项>
<选项>新建影LT; /选项>
<选项>新建电影2'; /选项>
< /选择>< /中心及GT;
< / TD>< / TR>


解决方案

您在找什么叫AJAX。你可以做手工,或更好的使用JavaScript库如MooTools的,jQuery的,或原型。

查看。我会避免W3Schools的教程。

只是为了涵盖所有的基础,为什么你就不能有用户提交表单?

此外,您可以用饼干做到这一点,虽然你不会得到服务器上的cookie的值,直到从用户的下一个GET或POST。

I know you cant save javascript variables into server side variables (vbscript) directly, but is there a way around this like saving java script variables into html hidden inputs then using javascript to post. Is this possible? If not what else can i do? Below is my code so far get the value of a drop down list - javascript

        function selectedDatabase() {

            select_temp = form1.elements["selection"];
            select_index = select_temp.selectedIndex;
            select_text = select_temp.options[select_index].text;

        }

Below is the HTML code

<center><select id="selection" onchange="selectedDatabase()">
<option>Movies</option>
<option>Movies 2</option>
<option>New Movies</option>
<option>New Movies 2</option>
</select></center>
</td></tr>
解决方案

What you're looking for is called ajax. You can do it manually, or better use a JavaScript library such as MooTools, jQuery, or Prototype.

Check out Google University's Ajax tutorial. I would avoid w3schools' tutorials.

Just to cover all the bases, why can't you just have the user submit the form?

Also, you could do this with cookies, though you won't get the cookie values on the server until the next GET or POST from the user.

这篇关于在服务器端保存变量JavaScript变量(VBScript)的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-22 13:32