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 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Jul 2002
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Two javascripts on one page?

    Hi there,
    Could someone please help me - I am trying to put more than one javascript on one page and they just don't seem to like each other - only one works.
    Is there a special function I need to put it to enable them to work alongside each other?
    Thanks for any help

  • #2
    New Coder
    Join Date
    Jul 2002
    Location
    USA, East Coast
    Posts
    43
    Thanks
    0
    Thanked 0 Times in 0 Posts

    same function name?

    are you including any .js files? or placing the code in the .html file itself?

    as long as the function names are different then they should be ok.

    do both work separatly? I am wondering if one of the scripts is broken.

    In javascript if there is any problems in any of the scripts you can have the whole thing not work.

    -S. Bob

  • #3
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,990
    Thanks
    203
    Thanked 2,536 Times in 2,514 Posts
    You can have as many scripts as you want.

    Have a look at:-

    http://www.javascriptkit.com/javatut...ntaction.shtml

    In short, the idea is

    onload=" dothis(); dothat(); dotheother;"

    that is, separating with semi-colons.

  • #4
    New Coder hedbanger's Avatar
    Join Date
    Jun 2002
    Location
    vallejo, ca
    Posts
    60
    Thanks
    0
    Thanked 0 Times in 0 Posts
    this info is inherent in the previous posts but i just thought it might help to stress it:
    if the two scripts don't have any naming conflicts, then making sure that in the header section, there's a semicolon at the end of the first script is often all it takes to make them both work.
    jf~ if you're not part of the solution, you're part of the precipitate.

  • #5
    New to the CF scene
    Join Date
    Jul 2002
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile Thank you!

    Thanks all of you - I've taken all your comments in hand and I'm double checking functions, variables etc - and all the other fun stuff you all suggested!
    Thanks so much for your speedy and very helpful replies!


  •  

    Posting Permissions

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