 |
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0 |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|

April 30th, 2004, 06:27 AM
|
Registered User
|
|
Join Date: Apr 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Passing values from asp to a javascript
Hello,,
I am using a javascript menu where the Caption of the page to redirect is given and the url for this page is to be taken dynamically from the database.
I can access the database and get the values using asp. But how to pass this url and caption to the javascript menu function because i am not getting the asp variables inside javascript
Thank you...
|

April 30th, 2004, 11:35 AM
|
Friend of Wrox
|
|
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
You can pass variables to JavaScript by writing to the script on the page with your ASP:
<script language=javascript>
var variable1 = '<%="hello"%>';
</script>
My ASP may be a bit messed up, as I don't know ASP very well.
Let me know if it works for you.
Snib
<><
|
The Following User Says Thank You to Snib For This Useful Post:
|
|

April 30th, 2004, 02:12 PM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
The above JavaScript by Snib is correct; you can use a variable like above to place in your javascript, just remember that you have to have a string around the ASP like so:
'<%=strVariable%>';
Also note that you can't pass JavaScript to ASP.
Brian
|

May 12th, 2004, 08:51 PM
|
Authorized User
|
|
Join Date: Apr 2004
Posts: 87
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
the syntax is correct BUT it do'nt work for me !
Is there any idea ?
|

May 13th, 2004, 06:09 AM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Can you post the line where you actually use that?
-Vijay G
|

May 13th, 2004, 06:47 AM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
If you are using a variable, also post where that variable get's its value from, maybe that will shed some light on the subject.
|

May 14th, 2004, 11:52 PM
|
Authorized User
|
|
Join Date: Apr 2004
Posts: 87
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
quote:Originally posted by happygv
Can you post the line where you actually use that?
-Vijay G
|
<SCRIPT language=javaSCRIPT>
var howpage ='<%="iPageCount"%>';
if( howpage>2){
document.frm1.cmdsubmit.style.visibility="visible" ;
}
else
{
document.frm1.cmdsubmit.style.visibility="hidden";
}
</SCRIPT>
iPageCount is PageCount of the Recordset Object
BUT If I wrote :
var howpage =3;
if( howpage>2){
document.frm1.cmdsubmit.style.visibility="visible" ;
}
else
{
document.frm1.cmdsubmit.style.visibility="hidden";
}
</SCRIPT>
It work correctly !
How do you think about that !
Thank you for your reply
|

May 15th, 2004, 04:17 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
When you look at the source of the page in the browser, what do you see?
Does howpage get a valid value?
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
|

May 15th, 2004, 07:20 AM
|
Friend of Wrox
|
|
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
My guess is that it gets set to the string "iPageCount". I think what you want to replace the line
var howpage = '<%="iPageCount"%>';
with
var howpage = '<%=iPageCount%>';
HTH,
Snib
<><
|

May 15th, 2004, 07:39 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Good catch, eagle-eye!! I completely overlooked that one.
Cheers,
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
|
|
 |