Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Professional
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Professional For advanced coder questions in ASP 3. 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 Professional section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 30th, 2004, 02:50 PM
Registered User
 
Join Date: Nov 2004
Location: , , .
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default Using the Session Object and JavaScript

I have a simple function and I am not able to assign the value of Session("PALType") to variable "SesType". I created Session("PALType") from my login page. I can write the Session value to my page using "Response.Write Session("PALType")" in the body of my page successfully. But I cannot assign it's value or use the Session Object itself for use in my If Statement.

Are we allowed to use Session("") and JavaScript together?

I have tried using "", '', and no quotes on either side of Session("PALType") but using '' is the only way that did not produce a error. Any help would be appreciated. Thank you in advance.

Function code is below:

function AdVal()
{

var SesType = 'Session("PALType")';
var AdminVal

//document.writeln(SesType)

if (SesType == "W2")
       {
         //document.writeln(SesType);
         AdminVal = document.frmDeal.AdminFee.value = "W2";
               }
      else
       {
         //document.writeln(SesType);
         AdminVal = document.frmDeal.AdminFee.value = "1099";
           }

return AdminVal;
}
Reply With Quote
  #2 (permalink)  
Old November 30th, 2004, 08:55 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: High Wycombe, UK, United Kingdom.
Posts: 344
Thanks: 0
Thanked 1 Time in 1 Post
Default

try :


function AdVal()
{
     var SesType = <%=Session("PALType")%>;

     // set the default value
     var AdminVal='1099';

      if (SesType == 'W2')
      {
          AdminVal = document.frmDeal.AdminFee.value = "W2";
      }

      return AdminVal;
}
Reply With Quote
  #3 (permalink)  
Old November 30th, 2004, 09:18 PM
Registered User
 
Join Date: Nov 2004
Location: , , .
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for your help.

When I use your code sniplet I get the following error:
"Object Expected"

I am calling this function from the onblur event of a textbox using the following code:
<INPUT TYPE="Text" NAME="ProcessingFeeOutside" VALUE="0" onblur="AdVal()">


Rguidry

Reply With Quote
  #4 (permalink)  
Old November 30th, 2004, 09:30 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: High Wycombe, UK, United Kingdom.
Posts: 344
Thanks: 0
Thanked 1 Time in 1 Post
Default

I'm guessing that you are printing this out from ASP, so try the following instead, replace the line :

var SesType = <%=Session("PALType")%>;

with :

var SesType = '<%=Session("PALType")%>';
Reply With Quote
  #5 (permalink)  
Old November 30th, 2004, 09:33 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: High Wycombe, UK, United Kingdom.
Posts: 344
Thanks: 0
Thanked 1 Time in 1 Post
Default

You might also fine a Netscape based browser such as Netscape / Firefox helpful as they have a better Javascript Console and Debugger than IE does.
Reply With Quote
  #6 (permalink)  
Old December 1st, 2004, 05:52 AM
Authorized User
 
Join Date: Jun 2003
Location: Witham, Essex, United Kingdom.
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You could also try storing the session variable in a hidden form field and picking it up from there in your JS.

-------------------
System 3 2000 Limited
www.system3-2000.co.uk
Reply With Quote
  #7 (permalink)  
Old December 1st, 2004, 03:53 PM
Registered User
 
Join Date: Nov 2004
Location: , , .
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Greg. I get the same "Object Expected" error.

Reply With Quote
  #8 (permalink)  
Old December 1st, 2004, 03:57 PM
Registered User
 
Join Date: Nov 2004
Location: , , .
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Greg,

So you are saying that if I load Netscape and view my page in their browser I will have better debugging tools?

It would be nice to be able to debug and step through the code.

Reply With Quote
  #9 (permalink)  
Old December 1st, 2004, 06:56 PM
Registered User
 
Join Date: Nov 2004
Location: , , .
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you all for your help! I started over using a blank page and with everyone's advice I got it to work using the following code:

function AdVal()
{

var SesType = '<%=Session("PALType")%>';
var AdminVal;

if (SesType == "W2")
       {
        AdminVal = document.frmDeal.AdminFee.value = "W2";
               }
      else
       {
         //document.writeln(SesType);
         AdminVal = document.frmDeal.AdminFee.value = "1099";
           }

return AdminVal;
}

Reply With Quote
  #10 (permalink)  
Old December 1st, 2004, 07:11 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: High Wycombe, UK, United Kingdom.
Posts: 344
Thanks: 0
Thanked 1 Time in 1 Post
Default

These browsers have a much more informative Javascript Console and also use a Javascript debugger - Venkman I think. I find them very useful in that regard, but you need to remember that your JS Code much work in them and not just IE for them to be of any real use.
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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
javascript and the session object VictorVictor ASP.NET 2.0 Professional 3 April 1st, 2007 02:58 PM
javascript intellisense & session object VictorVictor ASP.NET 2.0 Professional 0 March 29th, 2007 10:59 AM
Session object keyvanjan Classic ASP Basics 1 January 25th, 2006 09:32 PM
Session Object mcinar Classic ASP Basics 9 January 9th, 2005 05:41 PM
session - javascript MartinK PHP How-To 2 November 17th, 2004 06:31 AM



All times are GMT -4. The time now is 11:19 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.