使用ASP变量 [英] Using ASP Variables

查看:72
本文介绍了使用ASP变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用ASP从数据库中获取数据,我在我的网站上使用了一段javascript

代码。我想在我的

javascript中使用数据库变量。我对javascript不太熟悉,但这里有一些信息

类似于我正在尝试做的事情。


<%

strFirstName = session(" FirstName")ASP代码

strLastName = session(" LastName")

%>


我想在javascript代码中使用变量。

Items [1] = [" First Name",strFirstName,""]

Items [2] = [" Last Name",strLastName,""]


请帮助或指向一个包含此解决方案的网站。非常感谢

你的帮助。


Craig

w1 **** @ hotSPAMmail.com (发送前删除垃圾邮件)

I use ASP to obtain data from a database and I have a piece of javascript
code I use on my website. I want to use the database variables in my
javascript. I''m not very familiar with javascript, but here is some info
similar to what I''m trying to do.

<%
strFirstName=session("FirstName") ASP code
strLastName=session("LastName")
%>

The javascript code I want to use the variables in.
Items[1]=["First Name", strFirstName,""]
Items[2]=["Last Name", strLastName,""]

Please help or point me to a website with this solution. Thanks much for
your help.

Craig

w1****@hotSPAMmail.com (remove SPAM before sending)

推荐答案

Craig L写道:
Craig L wrote:
我使用ASP从数据库中获取数据,我在我的网站上使用了一段javascript
代码。我想在我的
javascript中使用数据库变量。我对javascript不太熟悉,但这里有一些类似于我正在尝试做的事情。

<%
strFirstName = session(" ; FirstName")ASP代码
strLastName = session(" LastName")
%>

javascript代码我想使用变量。
项目[1] = [" First Name",strFirstName,""]
Items [2] = [" Last Name",strLastName,""]
I use ASP to obtain data from a database and I have a piece of javascript
code I use on my website. I want to use the database variables in my
javascript. I''m not very familiar with javascript, but here is some info
similar to what I''m trying to do.

<%
strFirstName=session("FirstName") ASP code
strLastName=session("LastName")
%>

The javascript code I want to use the variables in.
Items[1]=["First Name", strFirstName,""]
Items[2]=["Last Name", strLastName,""]




您无法直接访问ASP变量,因为ASP在

服务器上完成,而Javascript在客户端(Web浏览器)上。当

Javascript正在执行时ASP已经完成了。


你可以试试这个: -


项目[1] = [" First Name"," ;<%= strFirstName%>",""]

Items [2] = [" Last Name","<%= strLastName%>", "]


HTH!


bengee



You can''t access the ASP variables directly, because ASP is done on the
server, and Javascript is on the client (web browser). By the time the
Javascript is "executing" the ASP has already finished.

You can try this though :-

Items[1]=["First Name", "<%=strFirstName%>",""]
Items[2]=["Last Name", "<%=strLastName%>",""]

HTH!

bengee


我已经做了类似以下的事情来将ASP变量变成javascript


<%

strFirstName =(无论你希望它等于什么)

strLastName =(无论你想要它等于什么)


Response.Write"< script language = JavaScript>"

Response.Writevar sFirstName =" &安培; strFirstName

Response.Write" var sLastName =" &安培; strLastName

Response.Write"< / script>"


现在,您的JavaScript可以使用变量sFirstName和sLastName


你做了什么,写成< script>阻止通过ASP给你

JavaScript变量....


迈克


" Craig L" < W1 ****** @ hotSPAMmail.com>在消息中写道

news:w8 ******************** @ comcast.com ...
I''ve done something like the following to get ASP variables into javascript

<%
strFirstName = (whatever you want it to equal)
strLastName = (whatever you want it to equal)

Response.Write "<script language=JavaScript>"
Response.Write "var sFirstName=" & strFirstName
Response.Write "var sLastName=" & strLastName
Response.Write "</script>"

Now, the variables sFirstName and sLastName are available to your JavaScript

What you have done, is written a <script> block via ASP that gives you
JavaScript variables....

Mike

"Craig L" <w1******@hotSPAMmail.com> wrote in message
news:w8********************@comcast.com...
I使用ASP从数据库中获取数据,我在我的网站上使用了一段javascript
代码。我想在我的
javascript中使用数据库变量。我对javascript不太熟悉,但这里有一些类似于我正在尝试做的事情。

<%
strFirstName = session(" ; FirstName")ASP代码
strLastName = session(" LastName")
%>

javascript代码我想使用变量。
项目[1] = [" First Name",strFirstName,""]
Items [2] = [" Last Name",strLastName,""]

帮助或指向我使用此解决方案的网站。非常感谢你的帮助。

克雷格

w1 **** @ hotSPAMmail.com (发送前删除垃圾邮件)
I use ASP to obtain data from a database and I have a piece of javascript
code I use on my website. I want to use the database variables in my
javascript. I''m not very familiar with javascript, but here is some info
similar to what I''m trying to do.

<%
strFirstName=session("FirstName") ASP code
strLastName=session("LastName")
%>

The javascript code I want to use the variables in.
Items[1]=["First Name", strFirstName,""]
Items[2]=["Last Name", strLastName,""]

Please help or point me to a website with this solution. Thanks much for
your help.

Craig

w1****@hotSPAMmail.com (remove SPAM before sending)



Bengee:

谢谢救命。 <%= info没有帮助。如果我为变量创建会话对象,你知道javascript

代码是否可以使用它?我尝试了一些

但没有运气。


Craig


" bengee" < PO ******** @的localhost.localdomain>在消息中写道

新闻:L8 ****************** @ wards.force9.net ...
Bengee:
Thanks for the help. the <%= info didn''t help. Do you know if the javascript
code can use it if I create a session object for the variable? I tried some
of this with no luck.

Craig

"bengee" <po********@localhost.localdomain> wrote in message
news:L8******************@wards.force9.net...
克雷格L写道:
我使用ASP从数据库中获取数据,我在我的网站上使用了一块
javascript代码。我想在我的
javascript中使用数据库变量。我对javascript不太熟悉,但这里有一些类似于我正在尝试做的事情。

<%
strFirstName = session(" ; FirstName")ASP代码
strLastName = session(" LastName")
%>

javascript代码我想使用变量。
项目[1] = [" First Name",strFirstName,""]
Items [2] = [" Last Name",strLastName,""]
I use ASP to obtain data from a database and I have a piece of javascript code I use on my website. I want to use the database variables in my
javascript. I''m not very familiar with javascript, but here is some info
similar to what I''m trying to do.

<%
strFirstName=session("FirstName") ASP code
strLastName=session("LastName")
%>

The javascript code I want to use the variables in.
Items[1]=["First Name", strFirstName,""]
Items[2]=["Last Name", strLastName,""]


<你无法直接访问ASP变量,因为ASP是在服务器上完成的,而Javascript是在客户端(Web浏览器)上。当Javascript正在执行时ASP已经完成了。

你可以试试这个: -

Items [1] = [" First Name","%= strFirstName%> ;",""]
Items [2] = [" Last Name","<%= strLastName%>",""]

> HTH!

bengee



You can''t access the ASP variables directly, because ASP is done on the
server, and Javascript is on the client (web browser). By the time the
Javascript is "executing" the ASP has already finished.

You can try this though :-

Items[1]=["First Name", "<%=strFirstName%>",""]
Items[2]=["Last Name", "<%=strLastName%>",""]

HTH!

bengee



这篇关于使用ASP变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆