how to call multiple functions using a button

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • deepthisoft
    New Member
    • Jul 2007
    • 27

    how to call multiple functions using a button

    hai,

    I have 2 javascript funtions.I want to call these 2 functions using one button.

    my code is like this,

    [html]
    <input type="button" value="ok" onclick="valida te(this),change ()">
    [/html]

    It is working.But after executing the first function its automatically goes to the second function.Within the first function i have displayed some messages using innerhtml and also it returns false. The messages are also displayed but the second function also executing.The control automatically goes to the next page.

    Can enybody please help me.
    Last edited by acoder; Aug 15 '07, 10:50 AM. Reason: proper code tags
  • Logician
    New Member
    • Feb 2007
    • 210

    #2
    Originally posted by deepthisoft
    hai,

    I have 2 javascript funtions.I want to call these 2 functions using one button.

    my code is like this,

    [code:html]
    <input type="button" value="ok" onclick="valida te(this),change ()">
    [/code:html]

    It is working.But after executing the first function its automatically goes to the second function.Within the first function i have displayed some messages using innerhtml and also it returns false. The messages are also displayed but the second function also executing.The control automatically goes to the next page.
    Presumably you mean that you want to execute the second function only when the first returns true.
    You haven't shown what change does, but if it could return true either on 'success' or always, then you could use:
    Code:
    onclick="return(validate(this) && change())"

    Comment

    • misaw
      New Member
      • Aug 2007
      • 17

      #3
      Originally posted by deepthisoft
      hai,

      I have 2 javascript funtions.I want to call these 2 functions using one button.

      my code is like this,

      [html]
      <input type="button" value="ok" onclick="valida te(this),change ()">
      [/html]

      It is working.But after executing the first function its automatically goes to the second function.Within the first function i have displayed some messages using innerhtml and also it returns false. The messages are also displayed but the second function also executing.The control automatically goes to the next page.

      Can enybody please help me.
      What i understand is 2nd function conditionally executed if first returns true
      else do not want to run 2nd function which changes the page...

      to do this

      [CODE=javascript]
      <input type="button" value="ok" onclick="OnClic kCall(this)">

      function OnClickCall(obj ){
      if(validate(obj )){
      change();
      }
      }
      [/CODE]
      Last edited by acoder; Aug 15 '07, 10:49 AM. Reason: complete code tags

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        Thanks everybody for using code tags. Shame that it didn't quite turn out right.

        To use them properly, use [ CODE=javascript] (without the space) and substitute the language of your choice, e.g. html, php. Close them with [/CODE]. Thanks!

        Comment

        Working...