Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

controlling when scripts run

Status
Not open for further replies.

OhioSteve

MIS
Mar 12, 2002
1,352
US
Hi! I have a fair amount of IT experience, but I am new to web programming. I just reviewed a tutorial on VBscript, and it seems to add a tremendous amount of functionality to HTML. This is my question. How do you control when the script executes? How do you say, &quot;Script, don't run until the user clicks this hyperlink!&quot; It seems to me that normal HTML executes sequentially. So it would seem that as soon as the browser hits the &quot;<script>&quot; tag, the script would run.
 
My question had two parts-

1) how can I stop the code from running initially?
2) how do I tell it to run when the appropriate event happens?

Since I posted my question, I have learned that subs and functions are not read in the first pass. So that answers (1). I could put a script at the top of the page with a bunch of subs, and they would not run initially.

But what about (2)??? How do I say, &quot;when they press the button [or hyperlink], run mySub?&quot;
 
one thing I would watch for is sub routines and functions differ in parameter passing. a function should be used for this task if you want to pass values from the user to interact.

on the quetion of calling a function or sub
the call statement for in the script calls

then you use events to call on user actions
NOTE: these are javascript defined events but mostly available in vbscript as well.

____________________________________________________
The most important part of your thread is the subject line.
Make it clear and about the topic so we can find it later for reference. Please!! faq333-2924

onpnt2.gif
 
Okay after going to the guru site and reviewing some other materials, I think that I have the answer. Buttons can have the attribute &quot;onclick&quot;. So &quot;onclick=mySub()&quot; will kick off mysub when they click the button.
 
just watch out for case in the event handlers. eg:
onClick=&quot;mySub()&quot;

you can also call them in vbscript with the
Sub MyButton_OnClick

____________________________________________________
The most important part of your thread is the subject line.
Make it clear and about the topic so we can find it later for reference. Please!! faq333-2924

onpnt2.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top