Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Javascript in ASP

Status
Not open for further replies.

TickleMeEmo

Programmer
Feb 20, 2003
9
0
0
US
Or ASP in Javascript
I have a nifty little Javascript that randomly pulls a quote.
The goal is that a user can then send this specific quote to another user's email address.
No problem right?
I'm getting hung up when I try to stick my Javascript variable in ASP, so my sendmail.asp page can send the quote.

pageone.asp has
this
<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
<!--
var quote = (tips[Math.round(Math.random()*(quote.length - .5))]);
var id =(Math.round(Math.random()*(quote.length - .5)));
document.write(quote);
// -->
</SCRIPT>
then i pass the id in the url to the next page
I now have my id

pagetwo.asp is just a form that collects who its from and who it goes too and who sent it

sendemail.asp?id=whatever the id is

I use Javascript to pull the quote
<!--
varvalue = document.location.search.substring(4);
var quote = (quote[id]);
// -->
</SCRIPT>
This all works
Now i want to declare an asp varible and set it to my javascript variable but I don't know the syntax.

I have a variable in javascrite now call quote and I want it to be equal to a ASp varible called quote.

Can you use ASP inside of javascript or Javascript inside of ASP?


 
You should use vbScript server-side on page 2

If your queryString looks like this...

sendemail.asp?id=234&url=espn.com

get them like this...

id = request(&quot;id&quot;)
url = request(&quot;url&quot;)


Get the Best Answers! faq333-2924
Is this an asp FAQ? faq333-3048
Tek-Tips Best Practices: FAQ183-3179
mikewolf@tst-us.com (Do not email regarding this thread unless requested - I don't check this account regularly)
 
Actually, what I want to do is make the following javascript variable be sent by my ASP email page
The javascript is
<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
<!--
id = document.location.search.substring(4);
var javascript_quote = (quote[id]);
// -->
</SCRIPT>
the javascript variable quote is now equal to the quote

I want something that looks like
<%
dim asp_quote
asp_quote= javascript_quote
%>
and then I'll take asp_quote and send it in the email


 
So, you're loading the quote() array on the client side? Remember that the asp is executed server-side BEFORE anything ever happens on the client side. Once the asp sends the HTML output to the client, the server-side is done and no longer executes until another page is called. So you have two options....


Load your array server side or recall the page with the quote sent as a variable in the request object...

I can help you do either. I'm sorry if I'm not getting what you're trying to do - maybe I need some caffiene... Get the Best Answers! faq333-2924
Is this an asp FAQ? faq333-3048
Tek-Tips Best Practices: FAQ183-3179
mikewolf@tst-us.com (Do not email regarding this thread unless requested - I don't check this account regularly)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top