Richard Korts
asked on
Javascript not working
I have this code:
and this:
<form method="POST" name="st" action="testers.php?tp=u" onSubmit="return chk_vals();">
The javascript variable ac (further up) is defined.
This is the form submit.
The page displayed after submit is testers.php. I am trying to force it to testersn.php if the user is 2 (me).
Why does that part not work?
I can show the entire HTML page if need be, I'm trying to simplity things.
Thanks
function chk_vals() {
if (ac == "c") {
if (tp == "u") {
document.st.action = "choose_cust.php";
} else {
document.st.action = "index.php";
}
return true;
}
if (document.st.firm.value == "" || document.st.faddr.value == "" || document.st.fcity.value == "" || document.st.fzip.value == "" || document.st.fst.value == "" || document.st.fphone.value == "" || document.st.pwd.value == "" || document.st.email.value == "" || document.st.pname.value == "") {
alert("All form values required.");
return false;
}
if (!document.st.agtc.checked) {
alert("You must agreed to the terms & conditions before proceeding.");
return false;
}
if (tp == "u") {
if (document.st.pwdr.value == "") {
return true;
}
}
if (document.st.pwd.value != document.st.pwdr.value) {
alert("Passwords do not match.");
return false;
}
if(user == 2) {
document.st.action = "testersn.php?tp=u";
}
return true;
}
and this:
<form method="POST" name="st" action="testers.php?tp=u" onSubmit="return chk_vals();">
The javascript variable ac (further up) is defined.
This is the form submit.
<div class="row">
<div class="col-xs-8 text-center col-xs-offset-2" style="padding-top:10px;"><input type="submit" value="Update Tester Data"><span style="padding-left:150px;"><input type="submit" value="Cancel" onMousedown="ac='c';"></span></div>
</div>
The page displayed after submit is testers.php. I am trying to force it to testersn.php if the user is 2 (me).
Why does that part not work?
I can show the entire HTML page if need be, I'm trying to simplity things.
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
tp = "u";
function chk_vals() {
if (ac == "c") {
if (tp == "u") {
document.st.action = "choose_cust.php";
} else {
document.st.action = "index.php";
}
return true;
}
if (document.st.firm.value == "" || document.st.faddr.value == "" || document.st.fcity.value == "" || document.st.fzip.value == "" || document.st.fst.value == "" || document.st.fphone.value == "" || document.st.pwd.value == "" || document.st.email.value == "" || document.st.pname.value == "") {
alert("All form values required.");
return false;
}
if (!document.st.agtc.checked
alert("You must agreed to the terms & conditions before proceeding.");
return false;
}
if (tp == "u") {
if (document.st.pwdr.value == "") {
return true;
}
}
Since tp = u, it never GETS to that point. Of course I should have seen that, but you know how it goes.
Thanks,
Richard