Hi
I'm working with a form that calculates different variables. It uses javascript, I tested the code and it works. I read the FAQ on how to implement the script into chronoforms. So I used the
Is there a simple reason for this, that would make me look like an ...😶 ?
HTML:
Javascript:
I'm working with a form that calculates different variables. It uses javascript, I tested the code and it works. I read the FAQ on how to implement the script into chronoforms. So I used the
var form = document.ChronoContact.my_form;
as it can be seen below. But this approach doesn't seem to work. I also tried instead replacing my_form with 'ChronoContact.my_form', but didn't work either. I also noticed that if I tested the form in dreamweaver and replaced my_form with 'ChronoContact.my_form' or something else before the dot, it wouldn't work.Is there a simple reason for this, that would make me look like an ...😶 ?
HTML:
<TABLE BORDER="1" WIDTH="35%" BGCOLOR="">
<TR>
<TD WIDTH="53%"><B>Age</B></TD>
<TD WIDTH="16%"><B>persons</B></TD>
<TD WIDTH="17%"><B>nights</B></TD>
<TD WIDTH="14%"><B>€</B></TD>
</TR>
<TR>
<TD>Adults</TD>
<TD>
<CENTER>
<P><INPUT TYPE="TEXT" NAME="Qty1" SIZE="5"
onBlur="Calculate();">
</CENTER>
</TD>
<TD>
<CENTER>
<INPUT TYPE="TEXT" NAME="Qtz1" SIZE="5"
onBlur="Calculate();">
</CENTER>
</TD>
<TD><INPUT TYPE="TEXT" NAME="Cost1" SIZE="8"></TD>
</TR>
<TR>
<TD>children < 10 y</TD>
<TD>
<CENTER>
<P><INPUT TYPE="TEXT" NAME="Qty2" SIZE="5"
onBlur="Calculate();">
</CENTER>
</TD>
<TD>
<CENTER>
<P><INPUT TYPE="TEXT" NAME="Qtz2" SIZE="5"
onBlur="Calculate();">
</CENTER>
</TD>
<TD><INPUT TYPE="TEXT" NAME="Cost2" SIZE="8"></TD>
</TR>
<TR>
<TD></TD>
<TD></TD>
<TD><B>total</B></TD>
<TD><INPUT TYPE="TEXT" NAME="Subtotal" SIZE="8" ></TD>
</TR>
</TABLE>
Javascript:
var form = document.ChronoContact.my_form;
function Calculate()
{
// calculate each line total
if (form.Qtz1.value == 1)
form.Cost1.value = form.Qtz1.value * 35;
else
form.Cost1.value = form.Qty1.value * form.Qtz1.value * 30;
if (form.Qtz2.value == 1)
form.Cost2.value = form.Qty2.value * 17.5;
else
form.Cost2.value = form.Qty2.value * form.Qtz2.value * 15;
form.Subtotal.value = parseFloat(form.Cost1.value)
+ parseFloat(form.Cost2.value);
}