ThatBloke
09-21-2011, 05:29 PM
Hi All
Javascript novice here so just need a bit of help. I'm sure it's something easy
I have a form, attributes below:
<form id="frmOrder" name="input" method="post" onsubmit="return OnSubmitForm();">
I need the deposit input value to match the total input value if the weeks10 checkbox is ticked. The reason for this is my client requires full payment if this box is ticked. This must be done upon form submission.
The reason for this is the email.php and payment.php submission pages collect the deposit value using $_POST and use that as the payment total
Attributes for inputs below:
Weeks10 checkbox:
<input type="checkbox" name="weeks10" id="weeks10" class="weeks10" />
Deposit input:
<input type="text" name="deposit" id="txtTotal3" readonly="readonly" size="2" value="0.00"></input>
Totals input:
<input type="text" readonly="readonly" id="txtTotal" value="0.00" size="2" name="total"/>
I'm using the following script:
<script type="text/javascript">
function OnSubmitForm()
{
if(document.input.weeks10[0].checked == true)
{
document.input.deposit.value = document.input.total.value;
}
return true;
}
function OnSubmitForm()
{
if(document.input.operation[0].checked == true)
{
document.input.action ="email.php";
}
else
if(document.input.operation[1].checked == true)
{
document.input.action ="payment.php";
}
return true;
}
</script>
The problem is, the second function works (email.php or payment.php action depending on radio selection). But the first one to adjust the total doesnt
Now I know my script is wrong so would somebody be kind enough to lend me a hand?
Thanks! :D
*Edit - forgot to mention the example is live here if you need to see the full code. It's a fairly complicated form (for me atleast anyway) http://lake-form.carpbookings.co.uk
Javascript novice here so just need a bit of help. I'm sure it's something easy
I have a form, attributes below:
<form id="frmOrder" name="input" method="post" onsubmit="return OnSubmitForm();">
I need the deposit input value to match the total input value if the weeks10 checkbox is ticked. The reason for this is my client requires full payment if this box is ticked. This must be done upon form submission.
The reason for this is the email.php and payment.php submission pages collect the deposit value using $_POST and use that as the payment total
Attributes for inputs below:
Weeks10 checkbox:
<input type="checkbox" name="weeks10" id="weeks10" class="weeks10" />
Deposit input:
<input type="text" name="deposit" id="txtTotal3" readonly="readonly" size="2" value="0.00"></input>
Totals input:
<input type="text" readonly="readonly" id="txtTotal" value="0.00" size="2" name="total"/>
I'm using the following script:
<script type="text/javascript">
function OnSubmitForm()
{
if(document.input.weeks10[0].checked == true)
{
document.input.deposit.value = document.input.total.value;
}
return true;
}
function OnSubmitForm()
{
if(document.input.operation[0].checked == true)
{
document.input.action ="email.php";
}
else
if(document.input.operation[1].checked == true)
{
document.input.action ="payment.php";
}
return true;
}
</script>
The problem is, the second function works (email.php or payment.php action depending on radio selection). But the first one to adjust the total doesnt
Now I know my script is wrong so would somebody be kind enough to lend me a hand?
Thanks! :D
*Edit - forgot to mention the example is live here if you need to see the full code. It's a fairly complicated form (for me atleast anyway) http://lake-form.carpbookings.co.uk