Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
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
 
Old April 30th, 2004, 06:27 AM
Registered User
 
Join Date: Apr 2004
Location: Banglore, Karnataka, India.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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...

 
Old April 30th, 2004, 11:35 AM
Friend of Wrox
 
Join Date: Nov 2003
Location: , , .
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

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:
aminlv (March 7th, 2017)
 
Old April 30th, 2004, 02:12 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Harrisburg, PA, USA.
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

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
 
Old May 12th, 2004, 08:51 PM
Authorized User
 
Join Date: Apr 2004
Location: , , .
Posts: 87
Thanks: 0
Thanked 0 Times in 0 Posts
Default

the syntax is correct BUT it do'nt work for me !
Is there any idea ?

 
Old May 13th, 2004, 06:09 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Can you post the line where you actually use that?

-Vijay G
 
Old May 13th, 2004, 06:47 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Harrisburg, PA, USA.
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

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.
 
Old May 14th, 2004, 11:52 PM
Authorized User
 
Join Date: Apr 2004
Location: , , .
Posts: 87
Thanks: 0
Thanked 0 Times in 0 Posts
Default



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






 
Old May 15th, 2004, 04:17 AM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

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.
 
Old May 15th, 2004, 07:20 AM
Friend of Wrox
 
Join Date: Nov 2003
Location: , , .
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

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

<><
 
Old May 15th, 2004, 07:39 AM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Good catch, eagle-eye!! I completely overlooked that one.

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.




Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing Form Values in ASP.Net sankar General .NET 10 September 21st, 2006 11:13 AM
Passing a ASP varible to a javascript tdaustin Classic ASP Basics 1 May 17th, 2005 01:44 AM
Passing values between Asp to Aspx page jayaraj General .NET 2 May 25th, 2004 01:16 AM
Passing values between Asp to Asp pages. jayaraj ASP.NET 1.0 and 1.1 Professional 3 May 23rd, 2004 06:53 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.