Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To 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 October 17th, 2005, 02:43 PM
1up 1up is offline
Authorized User
 
Join Date: Oct 2005
Location: , , .
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default Javascript and VBScript woes

Hi all, I have a n00b question for you all that I honestly dont know the answer to. Reason being, I am generally more of a Actionscript and XML guy than Javascript (which I can understand, modify and in some instances write) and know next to nothing about VBS.

I am co-developing a website that my partner (through telecommuting) has done a lot of content for. I "wrote" (modified rather) a time restricted button in Javascript to allow the user to advance after X seconds has gone by. That part works with a normal link perfectly, now I need to have my partners VBS link to work with it, but it seems to kill the Javascript whenever I add his link in (which works great outside of the Javascript function).

Heres the code for the Javascipt timer>

var secs
var timerID = null
var timerRunning = false
var delay = 1000

function InitializeTimer()
{
    secs = 5
    StopTheClock()
    StartTheTimer()
}
function StopTheClock()
{
    if(timerRunning)
        clearTimeout(timerID)
    timerRunning = false
}
function StartTheTimer()
{
    if (secs==0)
    {
        StopTheClock()
    self.status = "OK to proceed!"
    }
    else
    {
        self.status = secs
        secs = secs - 1
        timerRunning = true
        timerID = self.setTimeout("StartTheTimer()", delay)
    }
}
function GoToURL(){
if (self.status=="OK to proceed!")
{

open("courseTest.asp?courseID=<%=(courseContent.Fi elds.Item("courseID").Value)%>&chapterNum=<%=(cour seContent.Fields.Item("chapterNum").Value)%>&conte ntSection=<%=(courseContent.Fields.Item("forwardSe ction").Value)%>","_self")

}else{
alert("Not enough time has elapsed to proceed.")
}
}


Now I dont know if that can work with the Javascript or not, thats why Im here. Any input would be greatly appreciated.

Thanks!

Reply With Quote
  #2 (permalink)  
Old October 18th, 2005, 05:29 AM
Friend of Wrox
Points: 8,019, Level: 38
Points: 8,019, Level: 38 Points: 8,019, Level: 38 Points: 8,019, Level: 38
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2005
Location: Mauchline, East Ayrshire, Scotland
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default

Session.Timeout is the ASP/VB Script version of setTimeout in JavaScript

www.crmpicco.co.uk
Reply With Quote
  #3 (permalink)  
Old October 18th, 2005, 05:45 AM
Friend of Wrox
 
Join Date: Jul 2003
Location: , , United Kingdom.
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi 1up,

Session.Timeout is not equivalent to setTimeout

Your code looks like it should work. What does the function function GoToURL() look like when the page is built (in source view of your browser)?

Cheers,

Chris

Reply With Quote
  #4 (permalink)  
Old October 18th, 2005, 06:20 AM
Friend of Wrox
Points: 8,019, Level: 38
Points: 8,019, Level: 38 Points: 8,019, Level: 38 Points: 8,019, Level: 38
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2005
Location: Mauchline, East Ayrshire, Scotland
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default

Session.Timeout works in a similar way does it not?

It sets a minute value to a timeout???

www.crmpicco.co.uk
Reply With Quote
  #5 (permalink)  
Old October 18th, 2005, 07:48 AM
Friend of Wrox
 
Join Date: Jul 2003
Location: , , United Kingdom.
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

Session.Timeout sets the amount of time in minutes it takes for a users ASP session to expire, at which point any session variables for that user and cookies with session level scope etc are removed. It can be set by any ASP scripting language and not just VBScript.

setTimeout() specifies an amount of time in milliseconds to wait before executing a piece of code and is a method of the window object, so, if for example you have a VBScript block client-side, you could also use it there.

They work similarly in that they have a timer element, but so does my watch and that is not the real world equivalent of setTimeout() :D. Session.Timeout is not the ASP/VB Script version of setTimeout in JavaScript.

Reply With Quote
  #6 (permalink)  
Old October 18th, 2005, 10:10 AM
1up 1up is offline
Authorized User
 
Join Date: Oct 2005
Location: , , .
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

ChrisScott>

It looks like this:
open('"courseTest.asp?courseID=<%=(courseContent.F ields.Item("courseID").Value)%>&chapterNum=<%=(cou rseContent.Fields.Item("chapterNum").Value)%>&cont entSection=<%=(courseContent.Fields.Item("forwardS ection").Value)%>"',"_self")

...wordwrapped of course


The button that calls the function has this:

onClick="MM_callJS('GoToURL()')

...attached to it, and it works.

The page has a big block of text on it and due to state regulations, they must stay on the page for a minimum amount of time (anywhere from 30secs to 3 minutes), when the user clicks on the button, it determines if the timer has expired. If I use a regular URL like http://www.google.com or something of that nature, it works fine. Thats why I think there may be a syntax error in the VBS that breaks the JScript. That or they just dont work together. Do you think I should have the VBS spit the value out first and parse that link to Javascript, and if so, how would I go about doing that?

Thanks!

Reply With Quote
  #7 (permalink)  
Old October 18th, 2005, 10:15 AM
1up 1up is offline
Authorized User
 
Join Date: Oct 2005
Location: , , .
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Oh yeah, the end result from the VBS should be this:

courseTest.asp?courseID=300&chapterNum=1&contentSe ction=2

Thats if it works correctly.

I think I just might have to have it perfrom that script first and have the product put into a variable to be called on from GoToURL(). But, as I said, I really dont know that much about it.

Reply With Quote
  #8 (permalink)  
Old October 18th, 2005, 10:21 AM
Friend of Wrox
 
Join Date: Jul 2003
Location: , , United Kingdom.
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

Quote:
quote:
open('"courseTest.asp?courseID=<%=(courseContent.F ields.Item("courseID").Value)%>&chapterNum=<%=(cou rseContent.Fields.Item("chapterNum").Value)%>&cont entSection=<%=(courseContent.Fields.Item("forwardS ection").Value)%>"',"_self")
You don't need the single quotes around the url in this statement.

If you open the page in a browser & then view source (in the browser), how is this line being rendered - the vbscript should have been processed?

Cheers,

Chris

Reply With Quote
  #9 (permalink)  
Old October 18th, 2005, 11:13 AM
1up 1up is offline
Authorized User
 
Join Date: Oct 2005
Location: , , .
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Whoops, the single quotes were left over form another test I tried.
It didnt work without them either.

I am trying to log onto my partners FTP site to see if he entered the info correctly but I am waiting on the correct login info. That may explain something.

When I test the page, the VBS isnt processed since it isnt run off of the server. The view source shows me the same thing as I showed you.

Let me get back to you on that. I figure he had entered the VBS into the Jscript correctly and it was something else that was making the link not work right, I could be wrong though.

Reply With Quote
  #10 (permalink)  
Old October 18th, 2005, 11:32 AM
Friend of Wrox
 
Join Date: Jul 2003
Location: , , United Kingdom.
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

The code looks fine, but the link is not going to work if the VBScript is not getting processed, is the data in the link supposed by be static or dynamic?

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
Database Connection using VBScript (or) JavaScript reachsevar ASP.NET 1.0 and 1.1 Basics 1 November 27th, 2007 10:54 AM
JavaScript to VBScript Thomas82 Classic ASP Basics 1 July 29th, 2006 07:03 PM
Using VBScript variables in Javascript PL Classic ASP Basics 4 July 29th, 2004 03:05 PM
vbscript and javascript together erin VBScript 1 October 21st, 2003 02:48 PM
Using VBScript and JavaScript together jwalborn Classic ASP Professional 2 October 13th, 2003 10:06 AM



All times are GMT -4. The time now is 08:46 PM.


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