HTML, JavaScript And CSS Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingHTML, JavaScript And CSS Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old February 18th, 2004, 06:42 PM
johnbullkay johnbullkay is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 3 johnbullkay User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Variables between Javascript and ASP

I was wondering if anyone out there knows how i can pass a variable from my JavaCsript function to my ASP function.

I have a list from which I call a javascript function with onChange(javascript function). Inside that function, i want to pass a variable to an ASP function which will use it in a SQL query.

I have tried everything i can imagine but to no avail.

If that is not possible does anyone know how i can accomplish this in another way? I mean... can i call the ASP function directly from my onChange(asp function)? Or does an onChange require a script?

Thanks in advance for any suggestions that can be offered.

Reply With Quote
  #2  
Old February 20th, 2004, 11:47 PM
dcarva's Avatar
dcarva dcarva is offline
Contributing User
ASP Free Novice (500 - 999 posts)
 
Join Date: Jan 2003
Location: USA
Posts: 633 dcarva User rank is Lance Corporal (50 - 100 Reputation Level)dcarva User rank is Lance Corporal (50 - 100 Reputation Level)dcarva User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 9 h 18 m 20 sec
Reputation Power: 6
Hi,

I already answered this for you, but I wanted to post the answer as well:

You can't pass javascript variables to ASP functions. The ASP functions run server-side and have completed their execution once the page has loaded and the javascript is ready to be run.

Reply With Quote
  #3  
Old February 25th, 2004, 01:55 AM
Bullschmidt's Avatar
Bullschmidt Bullschmidt is offline
Guru
ASP Free Novice (500 - 999 posts)
 
Join Date: May 2003
Location: USA
Posts: 877 Bullschmidt User rank is Corporal (100 - 500 Reputation Level)Bullschmidt User rank is Corporal (100 - 500 Reputation Level)Bullschmidt User rank is Corporal (100 - 500 Reputation Level)Bullschmidt User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 1 Day 8 h 40 m 43 sec
Reputation Power: 9
And here's a little more info about mixing server-side ASP (which gets processed first) with client-side JavaScript.

It's easy to use the value of a VBScript variable in javascript:
document.writeln('<%= MyVBScriptVariable %>');

Or here is an example which puts the value of a VBScript variable into a JavaScript alert box:
Response.Write "<script language='JavaScript'>alert('The value is " & MyVBScriptVariable & "');</script>"

But to send the value of a JavaScript variable to VBScript, well that's another story. You could have the JavaScript fill in a hidden form field and then post the form. That way VBScript can pick up the value of the hidden form field with Request.Form("MyFieldName")
__________________
J. Paul Schmidt
www.Bullschmidt.com - Freelance Web and Database Developer
www.Bullschmidt.com/DevTip.asp - Classic ASP Design Tips

Reply With Quote
  #4  
Old August 11th, 2004, 08:38 AM
Omegon Omegon is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 1 Omegon User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
This is just a thought but maybe you can use it. (Even bothered to signup cause i was just looking for something myself).

If you make your ASP page and you implement your javascript in it.You could insert a hidden textfield

<input type="hidden" name="javascriptvariablename" value="javascriptvariablevalue">

Then you should submit the page to itself (leave the "action" property in your form tag empty).
Next put something in your asp code where you check if "server.request(javascriptvariablename) (i belive you request it that way, long time since i worked with asp i prefer php) you should do his to determine if it is the first time or the second time you load the page.

Then if that variable is not empty you can process it trough your query or whatever you want to do with it.

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingHTML, JavaScript And CSS Help > Variables between Javascript and ASP


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway