Click to See Complete Forum and Search --> : Form Problem


pk2000
09-03-2003, 12:13 PM
The following code is a simple javascript that does some basic calculations it takes static values and multiplies them by user input resulting in a subtotal for each time and a grandtotal of all the subtotals. The only problem is that the form when you click submit it shoud email itself to me but it doesnt. The present way it is. Now if I move the line "<FORM NAME="sunshineform">" to beneath the lines of "<form action="formmail.pl" method=POST>
<input type=hidden name="recipient" value="dimensionaljump@hotmail.com">
<input type=hidden name="subject" value="Online Quote Request Form">
<!--Title - title of the Your Message Was Sent resultant web page-->
<input type=hidden name="title" value="Online Quote Request Form">
<input type=hidden name="redirect" value="thankyou.html">"

It will THEN EMAIL the form to me, but it will not PERFORM the calculations.

Does anyone have any idea of what the problem is???


<HTML>
<Title></title>
<HEAD>
<SCRIPT language="JavaScript">
function Calculate()
{
if (sunshineform.Qtz1.value == 1)
sunshineform.Cost1.value = sunshineform.Qty1.value * 5;
else
sunshineform.Cost1.value = sunshineform.Qty1.value * sunshineform.Qtz1.value * 5;

if (sunshineform.Qtz2.value == 1)
sunshineform.Cost2.value = sunshineform.Qty2.value * 20;
else
sunshineform.Cost2.value = sunshineform.Qty2.value * sunshineform.Qtz2.value * 20;

if (sunshineform.Qtz3.value == 1)
sunshineform.Cost3.value = sunshineform.Qty3.value * 10;
else
sunshineform.Cost3.value = sunshineform.Qty3.value * sunshineform.Qtz3.value * 10;

if (sunshineform.Qtz4.value == 1)
sunshineform.Cost4.value = sunshineform.Qty4.value * 20;
else
sunshineform.Cost4.value = sunshineform.Qty4.value * sunshineform.Qtz4.value * 20;

sunshineform.Subtotal.value = parseFloat(sunshineform.Cost1.value) + parseFloat(sunshineform.Cost2.value) + parseFloat(sunshineform.Cost3.value) + parseFloat(sunshineform.Cost4.value);
}
</SCRIPT>
</HEAD>
<FORM NAME="sunshineform">
<form action="formmail.pl" method=POST>
<input type=hidden name="recipient" value="dimensionaljump@hotmail.com">
<input type=hidden name="subject" value="Online Quote Request Form">
<!--Title - title of the Your Message Was Sent resultant web page-->
<input type=hidden name="title" value="Online Quote Request Form">
<input type=hidden name="redirect" value="thankyou.html">

<TABLE BORDER="1" WIDTH="55%" BGCOLOR="">
<TR>
<TD WIDTH="53%"><B>Article</B></TD>
<TD WIDTH="16%"><B>Quantity</B></TD>
<TD WIDTH="17%"><b>Cubic Ft. Per Item</b></TD>
<TD WIDTH="14%"><b>Total Cubic Ft. Per Item</b></TD>
</TR>
<TR>
<TD>Bench - Fireside - Piano</TD>
<TD>
<CENTER>
<P>
<INPUT TYPE="TEXT" NAME="Qty1" SIZE="5"
onBlur="Calculate();">
</CENTER>
</TD>
<TD>

<CENTER>
<p align="center"><font face="Arial">5 </font>
<INPUT TYPE="hidden" NAME="Qtz1" SIZE="5"
onBlur="Calculate();" value="1">
</CENTER>
</TD>
<TD>
<INPUT TYPE="TEXT" NAME="Cost1" SIZE="8">
</TD>
</TR>
<TR>
<TD>Bookcase - double door</TD>
<TD>
<CENTER>
<P>
<INPUT TYPE="TEXT" NAME="Qty2" SIZE="5"
onBlur="Calculate();">
</CENTER>
</TD>
<TD>
<CENTER>
<p align="center"><font face="Arial">20 </font>
<INPUT TYPE="hidden" NAME="Qtz2" SIZE="5"
onBlur="Calculate();" value="1">
</CENTER>
</TD>
<TD>
<INPUT TYPE="TEXT" NAME="Cost2" SIZE="8">
</TD>
</TR>
<TR>
<TD>Bookshelves</TD>
<TD>
<div align="center">
<input type="TEXT" name="Qty3" size="5"
onBlur="Calculate();">
</div>
</TD>
<TD>
<p align="center"><font face="Arial">10 </font>
<input type="hidden" name="Qtz3" size="5"
onBlur="Calculate();" value="1">
</TD>
<TD>
<input type="TEXT" name="Cost3" size="8">
</TD>
</TR>
<TR>
<TD>Wall unit -sectional ea.</TD>
<TD>
<CENTER>
<P>
<INPUT TYPE="TEXT" NAME="Qty4" SIZE="5"
onBlur="Calculate();">
</CENTER>
</TD>
<TD>
<CENTER>
<p align="center"><font face="Arial">20 </font>
<INPUT TYPE="hidden" NAME="Qtz4" SIZE="5"
onBlur="Calculate();" value="1">
</CENTER>
</TD>
<TD>
<INPUT TYPE="TEXT" NAME="Cost4" 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>
<center>
<input type="submit" name="Submit" value="Submit Form"></center>
</FORM>
</BODY>
</HTML>

Jona
09-03-2003, 12:18 PM
Combine the two forms into one, and keep the same name of the form as the one that it worked with.

[J]ona

AdamBrill
09-03-2003, 12:18 PM
Try this:<HTML>
<Title></title>
<HEAD>
<SCRIPT language="JavaScript">
function Calculate()
{
if (sunshineform.Qtz1.value == 1)
sunshineform.Cost1.value = sunshineform.Qty1.value * 5;
else
sunshineform.Cost1.value = sunshineform.Qty1.value * sunshineform.Qtz1.value * 5;

if (sunshineform.Qtz2.value == 1)
sunshineform.Cost2.value = sunshineform.Qty2.value * 20;
else
sunshineform.Cost2.value = sunshineform.Qty2.value * sunshineform.Qtz2.value * 20;

if (sunshineform.Qtz3.value == 1)
sunshineform.Cost3.value = sunshineform.Qty3.value * 10;
else
sunshineform.Cost3.value = sunshineform.Qty3.value * sunshineform.Qtz3.value * 10;

if (sunshineform.Qtz4.value == 1)
sunshineform.Cost4.value = sunshineform.Qty4.value * 20;
else
sunshineform.Cost4.value = sunshineform.Qty4.value * sunshineform.Qtz4.value * 20;

sunshineform.Subtotal.value = parseFloat(sunshineform.Cost1.value) + parseFloat(sunshineform.Cost2.value) + parseFloat(sunshineform.Cost3.value) + parseFloat(sunshineform.Cost4.value);
}
</SCRIPT>
</HEAD>
<form NAME="sunshineform" action="formmail.pl" method=POST>
<input type=hidden name="recipient" value="dimensionaljump@hotmail.com">
<input type=hidden name="subject" value="Online Quote Request Form">
<!--Title - title of the Your Message Was Sent resultant web page-->
<input type=hidden name="title" value="Online Quote Request Form">
<input type=hidden name="redirect" value="thankyou.html">

<TABLE BORDER="1" WIDTH="55%" BGCOLOR="">
<TR>
<TD WIDTH="53%"><B>Article</B></TD>
<TD WIDTH="16%"><B>Quantity</B></TD>
<TD WIDTH="17%"><b>Cubic Ft. Per Item</b></TD>
<TD WIDTH="14%"><b>Total Cubic Ft. Per Item</b></TD>
</TR>
<TR>
<TD>Bench - Fireside - Piano</TD>
<TD>
<CENTER>
<P>
<INPUT TYPE="TEXT" NAME="Qty1" SIZE="5"
onBlur="Calculate();">
</CENTER>
</TD>
<TD>

<CENTER>
<p align="center"><font face="Arial">5 </font>
<INPUT TYPE="hidden" NAME="Qtz1" SIZE="5"
onBlur="Calculate();" value="1">
</CENTER>
</TD>
<TD>
<INPUT TYPE="TEXT" NAME="Cost1" SIZE="8">
</TD>
</TR>
<TR>
<TD>Bookcase - double door</TD>
<TD>
<CENTER>
<P>
<INPUT TYPE="TEXT" NAME="Qty2" SIZE="5"
onBlur="Calculate();">
</CENTER>
</TD>
<TD>
<CENTER>
<p align="center"><font face="Arial">20 </font>
<INPUT TYPE="hidden" NAME="Qtz2" SIZE="5"
onBlur="Calculate();" value="1">
</CENTER>
</TD>
<TD>
<INPUT TYPE="TEXT" NAME="Cost2" SIZE="8">
</TD>
</TR>
<TR>
<TD>Bookshelves</TD>
<TD>
<div align="center">
<input type="TEXT" name="Qty3" size="5"
onBlur="Calculate();">
</div>
</TD>
<TD>
<p align="center"><font face="Arial">10 </font>
<input type="hidden" name="Qtz3" size="5"
onBlur="Calculate();" value="1">
</TD>
<TD>
<input type="TEXT" name="Cost3" size="8">
</TD>
</TR>
<TR>
<TD>Wall unit -sectional ea.</TD>
<TD>
<CENTER>
<P>
<INPUT TYPE="TEXT" NAME="Qty4" SIZE="5"
onBlur="Calculate();">
</CENTER>
</TD>
<TD>
<CENTER>
<p align="center"><font face="Arial">20 </font>
<INPUT TYPE="hidden" NAME="Qtz4" SIZE="5"
onBlur="Calculate();" value="1">
</CENTER>
</TD>
<TD>
<INPUT TYPE="TEXT" NAME="Cost4" 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>
<center>
<input type="submit" name="Submit" value="Submit Form"></center>
</FORM>
</BODY>
</HTML>However, you shouldn't use formmail, since anyone can use it off of your server to send spam..

pk2000
09-03-2003, 12:22 PM
Thanks jona and adam,


and adam ya I know they can, thats why in the formmail.pl file it is set up that only email can be sent from the specific web domain names with the static ip#'s of those domains listed, plus it can only be sent to one email address which is also listed with username and domain name. So basically its set up in a way, that only email can be sent from the domains of the website and only to me.

Thanks alot for your help

AdamBrill
09-03-2003, 12:45 PM
However, it is very simple to fake a referrer to take care of the "only submit from this domain" problem. Also, if you set your e-mail address in formmail.pl, then why do you still have it set in the form? Or is the hidden form field named "recipient" doing something else?