473,397 Members | 1,969 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

passing ASP variable to JScript...

this is the only method I found for splitting a QueryString in ASP... but now I need to use that variable/string in my JavaScript function... thanks

Expand|Select|Wrap|Line Numbers
  1. <%
  2. Dim imdbLink
  3. ID = Request.QueryString("u")
  4. ID_split = Split(ID, "/title/")
  5. imdbLink = ID_split(1)
  6. %>
  7.  
  8. <script language="javascript" runat="server">
  9. var theLink = imdbLink;
  10. ...
  11. </script>
  12.  
please note this is ServerSide JavaScript... so var imdbLink = "<%= imdbLink %>"; won't work. thanks
Mar 7 '08 #1
2 1540
jeffstl
432 Expert 256MB
You will have to pass the variable to javascript on an event.

That is the only way because the javascript executes locally on the users machine, the value of the variable will have to be already established on the output page. (In other words the javascript is only going to be able to work with variables on the local page, not the asp page that runs on the server)

So some local events you could use to pass your variable is
- onload in the body tag <body onload="MyJavaFunc(myvar)">
- onclick on a link on the page

Given what it looks like you are trying to do you will probably need to run your javascript onload in the body tag.
Mar 7 '08 #2
jeffstl
432 Expert 256MB
You will have to pass the variable to javascript on an event.

That is the only way because the javascript executes locally on the users machine, the value of the variable will have to be already established on the output page. (In other words the javascript is only going to be able to work with variables on the local page, not the asp page that runs on the server)

So some local events you could use to pass your variable is
- onload in the body tag <body onload="MyJavaFunc(myvar)">
- onclick on a link on the page

Given what it looks like you are trying to do you will probably need to run your javascript onload in the body tag.
OK, you specified you are using server side js. If that is the case I really don't know as typically I use javascript for local stuff. I don't know what order a page is rendered in when you are running both js and asp to generate a page.

If the js is running first, then asp, obviously it cant be done. If asp runs first then js this method you posted "should" work. Experts?......heh
Mar 7 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: timwap | last post by:
I hava a Java Applet that produces a DTMF tone at a certain time of day. There are 4 parameters to the Applet, they are hour = Hour of triggered event 00~23 min = minute of triggered event 00~59...
0
by: cschang | last post by:
I have a file upload module written in .aspx. I want to write the filename (just the name) uploaded back to the my parent .asp file (the ..aspx file was a pop-up window related to the .asp) so...
1
by: spiff | last post by:
I am very very new to jscript. What I want to do is set a variable in one frame of a page, and then reload another frame so that it uses the new variable. Is this possible? I want to have a...
8
by: Jade | last post by:
I saw some web page saying I could do it this way in javascript: var iNumber = <%#publicvarname publicpropertyname %> but it doesn't seem to work. I have this piece of code here in...
2
by: ad | last post by:
I have a Asp.Net project, it use JScript to program the client's script I declare a variable in web.config like: <add key="CompanyName" value="Big Salse company" /> How can I use the CompanyName...
6
by: ged | last post by:
Hi, i am a oo (c#) programmer, and have not used javascript for a while and i cant work out how javascript manages its references. Object References work for simple stuff, but once i have an...
20
by: weston | last post by:
I've got a piece of code where, for all the world, it looks like this fails in IE 6: hometab = document.getElementById('hometab'); but this succeeds: hometabemt =...
5
by: Ido.Yehieli | last post by:
Hi all, I'm new to c# and .net and I have a few questions I did not manage to find an answer to: 1. what is the equivalent to the "exec" command in python/lisp? meaning: a string is given as...
5
by: steve9013 | last post by:
Hello. Hoping someone can help me out with this. Please forgive me as I'm very new to jscript. I need to have the input box at the top of the page store the string to a variable. I then need...
1
globalguideline
by: globalguideline | last post by:
Hi all here at forum. I am working to find out some solution to access a web page in PHP that is showing information on the bases of given argument in query string variable. My problem is this that...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.