Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Saj
    Saj is offline
    Regular Coder
    Join Date
    Feb 2003
    Posts
    181
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to call a function from a conditional

    Basicly, I need to say:

    If this equals that, then do function test().

    Code:
    if(this==that) {
       test();
    }
    Thanks
    - Saj

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    FL, USA
    Posts
    734
    Thanks
    0
    Thanked 0 Times in 0 Posts
    your right on target Saj

    if(this==that){
    CallFunction()
    }

    It works for me and all of my scripts
    CYWebmaster.com - See why we dot com!!
    ACJavascripts.com - Cut & Paste Javascripts!
    SimplyProgram.com - Personal Blog

  • #3
    Saj
    Saj is offline
    Regular Coder
    Join Date
    Feb 2003
    Posts
    181
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Then what exactly would I do?

    if(this==that){
    CallFunction(test)
    }

    or

    if(this==that){
    Calltest()
    }
    - Saj

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Location
    FL, USA
    Posts
    734
    Thanks
    0
    Thanked 0 Times in 0 Posts
    you would put it like this

    if(this==that){
    Test()
    }

    ----

    function Test(){
    alert("Hi there,, I was called by a condition.")
    }
    CYWebmaster.com - See why we dot com!!
    ACJavascripts.com - Cut & Paste Javascripts!
    SimplyProgram.com - Personal Blog

  • #5
    Regular Coder
    Join Date
    Feb 2003
    Location
    California
    Posts
    925
    Thanks
    0
    Thanked 0 Times in 0 Posts
    it depends on if the function takes a parameter or not. if it does then there is someting in between the parenthesis otherwise there is nothing in between them.


    Jason

  • #6
    Saj
    Saj is offline
    Regular Coder
    Join Date
    Feb 2003
    Posts
    181
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Ohh duh. The first thing you said worked for me. I was actually putting it in the wrong function at first. I'm really going crazy.

    Thank though.
    - Saj


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •