If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Multiple calls with OnChange or OnClick

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-11-04, 09:36
rweide rweide is offline
Registered User
 
Join Date: Aug 2004
Location: USA
Posts: 54
Multiple calls with OnChange or OnClick

Can you execute two functions one after another with onclick or onchange event?
I'd like to 1) set the focus to a particular field; 2) execute a function with an onclick or onchange event.
Can this be done? and how?

Thanks.
Reply With Quote
  #2 (permalink)  
Old 11-11-04, 13:09
oliflorence oliflorence is offline
Registered User
 
Join Date: Aug 2004
Posts: 96
Hi,
you can create a function that calls other function, then you only have to call this function, that would be in javascript not in asp as you would have to reload the page to do so.

In JS:

Code:
 function funct1()
{
//have this function do what ever you want it to do

}

function funct2()
{
//same here with function 2

}

function callAboveFunctions()
{
funct1();
funct2();

}

In your html <a href="javascript:callAboveFunctions();">Click here to trigger the 2 fonctions</a>
Hope this helps
Reply With Quote
  #3 (permalink)  
Old 11-11-04, 14:52
rweide rweide is offline
Registered User
 
Join Date: Aug 2004
Location: USA
Posts: 54
Thanks, this does help.

But I guess I can't directly place two functions together in the onclick or onchange event.
Reply With Quote
  #4 (permalink)  
Old 11-15-04, 20:34
Seppuku Seppuku is offline
Useless...
 
Join Date: Jul 2003
Location: SoCal
Posts: 721
I think what rweide was getting at is this....

Code:
<script>
function func1() {
  //.....
}

function func2() {
  //.....
}

function doUpdate() {
  func1();
  func2();
}
</script>

<input type="text" name="myTextbox" onClick="doUpdate();" onChange="doUpdate();">
__________________
That which does not kill me postpones the inevitable.
Reply With Quote
  #5 (permalink)  
Old 11-16-04, 14:46
rweide rweide is offline
Registered User
 
Join Date: Aug 2004
Location: USA
Posts: 54
Hmm, this helps.

But what about <....onClick="doOneThing();" onClick="doAnotherThing();">??

Can you do something like that? Two function calls in one OnClick event?
Reply With Quote
  #6 (permalink)  
Old 11-16-04, 16:52
Seppuku Seppuku is offline
Useless...
 
Join Date: Jul 2003
Location: SoCal
Posts: 721
eh.. no.. you could do:

<....onClick="doOneThing(); doAnotherThing();">

or simply call a single function that calls doOneThing() and doAnotherThing()

Code:
<script>
function doOneThing() {
  //.....
}

function doAnotherThing() {
  //.....
}

function doUpdate() {
  doOneThing();
  doAnotherThing();
}
</script>

<input type="text" name="myTextbox" onClick="doUpdate();">
__________________
That which does not kill me postpones the inevitable.
Reply With Quote
  #7 (permalink)  
Old 11-17-04, 09:12
rweide rweide is offline
Registered User
 
Join Date: Aug 2004
Location: USA
Posts: 54
Thank you very much.
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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On