只执行一个功能

I have a .js file with these two functions:

function download510(form) { 
    if (form.pass.value=="tokheim") {              
        location="../pdf/quantium-510.pdf" 
    } else {
        alert("Invalid Password")
    }
};

function download410(form) { 
    if (form.pass.value=="tokheim") {              
        location="../pdf/quantium-410.pdf" 
    } else {
        alert("Invalid Password")
    }
};

And two .php files with:

1:

<form name="login">
    <input name="pass" type="password"> 
    <input type="button" value="Download" onClick="download510(this.form)">
</form>

2:

<form name="login">
    <input name="pass" type="password"> 
    <input type="button" value="Download" onClick="download410(this.form)">
</form>

Only the first function, download510(form), works. Any ideas would be much appreciated.

You don't indicate what you mean by 'not working' but one possible avenue would be to use onSubmit instead of onClick for your forms. If you want to block submission in the case of the incorrect password you return false from the function. Otherwise the form will be submitted.

Of course, this is in addition to all the other issues inherent in this code.. visible passwords, links, missing semi-colons.. etc...

This function

function download510(form) { 
   if (document.getElementById("pass").value=="tokheim") {              
      location="../pdf/quantium-510.pdf" ;
   } else {
      alert("Invalid Password");
   }
}

With this php file

<form name="login">
    <input name="pass" id="pass" type="password"> 
    <input type="button" value="Download" onClick="download510(this.form)">
</form>

And, this other function:

function download410(form) { 
    if (document.getElementById("pass").value=="tokheim") {              
        location="../pdf/quantium-410.pdf" ;
    } else {
        alert("Invalid Password");
    }
}

With this php file:

<form name="login">
    <input name="pass" id="pass" type="password"> 
    <input type="button" value="Download" onClick="download410(this.form)">
</form>

Dont use the 2 functions together; the same with the forms....if you try it to use together change the name of the value input, like:

<input name="pass1" id="pass1" type="password"> 

and

<input name="pass2" id="pass2" type="password">; 

Do the same with the names on each of the JS functions.

Saludos.