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

    Question stats using form validation

    Hi all.
    I'm new to java script I have been trying to work this several ways
    the user enters his name
    and three differnt shot types
    then a prompt window appears after the info is entered in the txt fields.
    I'm not trying to do pattern recognition just a simple form is all.
    So what am i ding wrong?
    when I take out the script marked red it works fine?



    </SCRIPT><SCRIPT LANGUAGE="JavaScript1.2">
    function validate(formCheck) //Function with a parameter representing a form name.
    {
    *** if (formCheck.name.value =="")
    *** {
    ******* alert("Please provide your name:");*
    ******* formCheck.name.focus();
    ******* return false;
    *** }


    Can I use the same function threetimes?It only seems to work when I use the below function once.
    function showPerc(freemade, freeatt){
    percent = ((1*freemade) / (1*freeatt))*100;


    message = "The pecent of "+freemade+" and "+freeatt+" is "+percent+".\n";
    alert(message);
    }

    Any suggestions, Thanxs

    Paul

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,172
    Thanks
    203
    Thanked 2,549 Times in 2,527 Posts
    You cannot have more than one function (or more than one global variable) with the same name.

    Rename the second and third functions and variables xxx2, xxx3 nd so forth.


  •  

    Posting Permissions

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