E
elia
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='Javascript'>
function setAction(name) {
if (name=="submit1")
document.forms[0].action= "invoice.php"
else if (name=="submit2")
document.forms[0].action= "credit_card.php"
}
</script>
and on the form:
<input type="submit" id="submit1" name="submit1"
onClick="setAction(this.name)"
<input type="submit" id="submit2" name="submit2"
onClick="setAction(this.name)"
....
and for the second action (check fields) :
<script type="text/javascript">
function verif_fields()
{
if(document.form1.name.value == "")
{
alert("Write your name");
document.forml.name.focus();
return false;
}
if(document.form.email.value == "")
{
alert("Write your email.......
....
return confirm("ok");
}
</script>
and in the form:
<form name="form1" method="post" onSubmit="return verif_fields()" >
I try to do like this but it doesn't work! :
<script type="text/javascript">
function verif_fields()
{
if(document.forml.name.value == "")
{
alert("Write your name");
document.forml.name.focus();
return false;
}
if(document.forml.email.value == "")
{
alert("Write your email ...
....
document.form1.action = button==1? "invoice.php" : "credit_card.php";
return confirm("Ok");
}
</script>
and in the form :
<form name="forml" method="post" onSubmit="return 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
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='Javascript'>
function setAction(name) {
if (name=="submit1")
document.forms[0].action= "invoice.php"
else if (name=="submit2")
document.forms[0].action= "credit_card.php"
}
</script>
and on the form:
<input type="submit" id="submit1" name="submit1"
onClick="setAction(this.name)"
<input type="submit" id="submit2" name="submit2"
onClick="setAction(this.name)"
....
and for the second action (check fields) :
<script type="text/javascript">
function verif_fields()
{
if(document.form1.name.value == "")
{
alert("Write your name");
document.forml.name.focus();
return false;
}
if(document.form.email.value == "")
{
alert("Write your email.......
....
return confirm("ok");
}
</script>
and in the form:
<form name="form1" method="post" onSubmit="return verif_fields()" >
I try to do like this but it doesn't work! :
<script type="text/javascript">
function verif_fields()
{
if(document.forml.name.value == "")
{
alert("Write your name");
document.forml.name.focus();
return false;
}
if(document.forml.email.value == "")
{
alert("Write your email ...
....
document.form1.action = button==1? "invoice.php" : "credit_card.php";
return confirm("Ok");
}
</script>
and in the form :
<form name="forml" method="post" onSubmit="return 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