Hello,
I can't do two actions wich must be done on a form having two buttons.
(payment by invoice and payment by Credit card)
The first action establishes a link on two differents pages according
to whether one wants to pay by invoice or credit card. (2 buttons send)
The second action is for check if all the fields were filled.
The two codes are ok by themselves but do not work together!
For the first action (links) I have:
<script language='Javas cript'>
function setAction(name) {
if (name=="submit1 ")
document.forms[0].action= "invoice.ph p"
else if (name=="submit2 ")
document.forms[0].action= "credit_card.ph p"
}
</script>
and on the form:
<input type="submit" id="submit1" name="submit1"
onClick="setAct ion(this.name)"
<input type="submit" id="submit2" name="submit2"
onClick="setAct ion(this.name)"
....
and for the second action (check fields) :
<script type="text/javascript">
function verif_fields()
{
if(document.for m1.name.value == "")
{
alert("Write your name");
document.forml. name.focus();
return false;
}
if(document.for m.email.value == "")
{
alert("Write your email.......
....
return confirm("ok");
}
</script>
and in the form:
<form name="form1" method="post" onSubmit="retur n verif_fields()" >
I try to do like this but it doesn't work! :
<script type="text/javascript">
function verif_fields()
{
if(document.for ml.name.value == "")
{
alert("Write your name");
document.forml. name.focus();
return false;
}
if(document.for ml.email.value == "")
{
alert("Write your email ...
....
document.form1. action = button==1? "invoice.ph p" : "credit_card.ph p";
return confirm("Ok");
}
</script>
and in the form :
<form name="forml" method="post" onSubmit="retur n verif_fields()" >
<input type="submit" id="submit1" name="submit1" onClick="button =1"
value="Invoice" >
<input type="submit" id="submit2" name="submit2" onClick="button =2"
value="Credit card">
Is somebody can help me? Thanks, pascal