If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > ASP and Javascript

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-24-06, 09:44
ymadhuri ymadhuri is offline
Registered User
 
Join Date: Nov 2005
Posts: 6
ASP and Javascript

I need to check a ASP variable value in a Javascript function , how do i do this?
Reply With Quote
  #2 (permalink)  
Old 02-24-06, 17:08
buzzter66 buzzter66 is offline
Registered User
 
Join Date: Nov 2002
Location: Houston, Texas
Posts: 85
Very easy, I do it all the time.

If you're using a form, just put the ASP variable into a hidden field and then have javascript check the value in the hidden field.

<form name="formName" id="formName">
<input type="hidden" name="varASP" id="varASP" value="<%= the.ASPvariable %>">
</form>

Then just have your Javascript read it normally:

var checkMe = document.forms['formName'].varASP.value;

-------------

A shorter way is to just skip the form (but it's useful to mention that first because most of the times I need to check an ASP variable it's usually for a form) and reference the ASP variable directly in the javascript:

var checkMe = "<%= the.ASPvariable %>";

Note the quotes around the ASP code. That's pretty important.

Good luck!
Reply With Quote
  #3 (permalink)  
Old 03-06-06, 20:38
Bullschmidt Bullschmidt is offline
Guru
 
Join Date: Jun 2003
Location: USA
Posts: 1,032
And for the same kind of answer in other words (that hopefully might give you some more ideas along the same lines):

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

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

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>"
__________________
J. Paul Schmidt, Freelance Web and Database Developer
www.Bullschmidt.com
Access Database Sample, Web Database Sample, ASP Design Tips
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On