PDA

View Full Version : Form Adder



Nate_Bro
09-25-2004, 05:56 AM
:eek: i had this working fine half way through, then i quit, adding the decimal numbers, and i can't find where i messed up, if you could help i would appreciate it, Thanks,
~Nate Bro :)


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
</head>
<body>
<form name="jj">
<table border="0" cellpadding="2" cellspacing="4" width="696" height="551">
<tr>
<td width="81" valign="top" height="16">
<p align="left"><b><font face="Arial" size="3">QUANTITY</font></b></p>
</td>
<td width="385" valign="top" height="16">
<p align="left"><b><font face="Arial" size="3">&nbsp;&nbsp;
DESCRIPTION</font></b></td>
<td width="10" valign="top" height="16">
</td>
<td width="70" valign="top" height="16">
<p align="left"><b><font face="Arial" size="3">PRICE</font></b></td>
<td width="93" valign="top" height="64" colspan="2" rowspan="4">
<p align="left">&nbsp;</td>
</tr>
<tr>
<td width="81" height="16" align="center" valign="middle">
<p align="left"><input type="text" name="T10" size="9"></td>
<td width="385" height="16">
<p align="left"><b><font face="Arial" size="2">&nbsp;&nbsp; Jericho Junction
Children's Church Production Kit (One Year complete Program)&nbsp;&nbsp;</font></b></td>
<td width="10" height="16">
<b><font face="Arial" size="4">$</font></b></td>
<td valign="middle" align="center" height="16" width="70">
<p align="left"><input type="text" name="T18" size="9" value="399.00"></td>
</tr>
<tr>
<td width="81" height="16" align="center" valign="middle">
<p align="left">
<input type="text" name="T9" size="9"></td>
<td width="385" height="16">
<p align="left"><b><font face="Arial" size="2">&nbsp;&nbsp; Jericho Junction
Video Training Seminar</font></b></td>
<td width="10" height="16">
<b><font face="Arial" size="4">$</font></b></td>
<td valign="middle" align="center" height="16" width="70">
<p align="left"><input type="text" name="T19" size="9" value="49.95"></td>
</tr>
<tr>
<td width="81" height="16" align="center" valign="middle">
<p align="left">
<input type="text" name="T8" size="9"><p align="left">
&nbsp;</td>
<td width="385" valign="middle" height="16">
<p align="left" style="margin-top: 0; margin-bottom: 0"><b><font face="Arial" size="2">&nbsp;&nbsp;
Jericho
Junction Children's Music CD</font></b><p align="left" style="margin-top: 0; margin-bottom: 0">
<b>
<font face="Arial" size="2"><font color="#000080">&nbsp;</font><font color="#FF0000">$12.95</font>
(1-24)&nbsp;&nbsp;&nbsp;&nbsp; <font color="#FF0000">$9.95</font> (25-49)&nbsp;&nbsp;&nbsp;&nbsp;
<font color="#FF0000">$7.95</font> (50 or more)</font>
</b>
<p align="left" style="margin-top: 0; margin-bottom: 0">
&nbsp;</td>
<td width="10" valign="middle" height="16">
<b><font face="Arial" size="4">$</font></b><p>&nbsp;</td>
<td valign="middle" align="right" height="16" width="70">
<p align="left"><input type="text" name="T20" size="9" value="12.95 "><p align="left">&nbsp;</td>
</tr>
<tr>
<td width="81" height="16" align="center" valign="middle">
<p align="left">
</td>
<td width="385" valign="top" align="left" height="16">
<p align="left"><b><font face="Arial" size="2">&nbsp;&nbsp; <font color="#FF0000">*</font>
Jericho Junction 100% Cotton T-Shirt</font></b></td>
<td width="10" valign="top" align="left" height="16">
</td>
<td valign="middle" align="right" height="16" width="70">
<p align="left"><b><font face="Arial" size="2">see below</font></b></td>
<td width="10" height="16">
<p align="left">&nbsp;</td>
<td width="73" height="16">
<p align="left">&nbsp;</td>
</tr>
<tr>
<td width="680" height="14" align="center" valign="middle" colspan="6">
</td>
</tr>
<tr>
<td width="81" height="16" align="center" valign="middle">
<p align="left">
<input type="text" name="T25" size="9"></td>
<td width="385" height="16">
<p align="left"><b><font face="Arial" size="2">&nbsp;&nbsp; Jericho Junction
Sound Effects CD</font></b></td>
<td width="10" height="16">
<b><font face="Arial" size="4">$</font></b></td>
<td valign="middle" align="center" height="16" width="70">
<p align="left"><input type="text" name="T26" size="9" value="7.95"></td>
<td width="10" height="16">
<p align="left">&nbsp; </td>
<td width="73" height="16">
<p align="left">&nbsp;</td>
</tr>
<tr>
<td width="81" height="16" align="center" valign="middle">
<p align="left">
<input type="text" name="T27" size="9"><p align="left">
&nbsp;</td>
<td width="385" height="16">
<p align="left"><b><font face="Arial" size="2">&quot;Search
for Hidden Treasures&quot; VBS Production Kit (5 Day Program)</font></b><p align="left">&nbsp;</td>
<td width="10" height="16">
<b><font face="Arial" size="4">$</font></b><p>&nbsp;</td>
<td valign="middle" align="center" height="16" width="70">
<p align="left"><input type="text" name="T28" size="9" value="99.95"><p align="left">&nbsp;</td>
<td width="10" height="16">
<p align="left">&nbsp;</td>
<td width="73" height="16">
<p align="left">&nbsp;</td>
</tr>

Nate_Bro
09-25-2004, 05:57 AM
Sorry, i had to split it in half


<tr>
<td width="81" height="16" align="center" valign="middle">
<p align="left">
&nbsp;</td>
<td width="385" valign="top" height="16">
<p align="left"><b><font face="Arial" size="2">&nbsp;&nbsp;<font color="#FF0000">
*</font> &quot;Search for Hidden Treasures&quot;&nbsp; 100% Cotton T-Shirt</font></b></td>
<td width="91" valign="top" height="16" colspan="2">
<p align="left"><b><font face="Arial" size="2">see
below</font></b></td>
<td width="10" height="16">
<p align="left">&nbsp;</td>
<td width="73" height="16">
<p align="left">&nbsp;</td>
</tr>
<tr>
<td width="680" height="14" align="center" valign="middle" colspan="6">
</td>
</tr>
<tr>
<td width="81" height="18" align="center" valign="middle">
<p align="left">
<input type="text" name="T39" size="9"></td>
<td width="385" height="18">
<p align="left"><b><font face="Arial" size="2">&nbsp;&nbsp; Kidz
Zone Curriculum&nbsp;(One Year Complete Program)</font></b></td>
<td width="10" height="18">
<b><font face="Arial" size="4">$</font></b></td>
<td align="center" valign="baseline" height="18" width="70">
<p align="left"><input type="text" name="T40" size="9" value="299.00"></td>
<td width="10" height="18">
<p align="left">&nbsp;</td>
<td width="73" height="18">
<p align="left">&nbsp;</td>
</tr>
<tr>
<td width="577" height="32" align="center" valign="middle" colspan="4">
<p align="left"><b><font face="Arial" size="2">Merchandise Total:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="Reset" value="Clear" name="B10">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></b>
<input type="button" value="Add my total" name="B3" onclick="grand(),grand1(),grand2(),grand3(),grand4(),grand5()"></td>
<td width="10" height="32" align="center" valign="middle">
<b><font face="Arial" size="4">$</font></b></td>
<td width="73" height="32" align="center" valign="middle">
<input type="text" name="total" size="9" value="0"></td>
</tr>
<tr>
<td colspan="4" valign="middle" align="right" height="28" width="577">
<p align="left"><b><font face="Arial" size="2">Shipping
&amp; Handling:&nbsp; (see chart below)</font></b></td>
<td width="10" height="28">
<p align="left"><b><font face="Arial" size="4">$</font></b></td>
<td width="73" height="28">
<p align="left"><input type="text" name="T47" size="9"></td>
</tr>
<tr>
<td colspan="4" valign="middle" align="right" height="28" width="577">
<p align="left"><b><font face="Arial" size="2">TOTAL
AMOUNT DUE:</font></b></td>
<td width="10" height="28">
<p align="left"><b><font face="Arial" size="4">$</font></b></td>
<td width="73" height="28">
<p align="left"><input type="text" name="T48" size="9"></td>
</tr>
</table>


<SCRIPT>


function grand(){
if (document.jj.T10.value == null, document.jj.T10.value == "")
document.jj.total.value = ( "0.00");
else if (document.jj.T10.value != null, document.jj.T10.value != "")
document.jj.total.value = ( document.jj.T10.value * 399.01 );

}
function grand1(){
if (document.jj.T9.value == null, document.jj.T9.value == "")
document.jj.total.value = ( parseInt(document.jj.total.value));
else if (document.jj.T9.value != null, document.jj.T9.value != "")
document.jj.total.value = ( parseInt(document.jj.total.value) + document.jj.T9.value * 49.95 );
else if (document.jj.total.value == null, document.jj.total.value == "")
document.number.total.value = document.jj.total.value;
}
function grand2(){

var n1 = document.jj.T8.value

if (document.jj.T8.value == null, document.jj.T8.value == "")
document.jj.total.value = ( parseInt(document.jj.total.value));
else if ( n1 >= 1, n1 <= 25)
document.jj.total.value = ( parseInt(document.jj.total.value) + n1 * 12.95);
else if ( n1 >= 26, n1 <= 49)
document.jj.total.value = ( parseInt(document.jj.total.value) + n1 * 9.95);
else if ( n1 >= 50, n1 <= 9000)
document.jj.total.value = ( parseInt(document.jj.total.value) + n1 * 7.95);
}

function grand3(){
if (document.jj.T39.value == null, document.jj.T39.value == "")
document.jj.total.value = ( parseInt(document.jj.total.value));
else if (document.jj.T39.value != null, document.jj.T39.value != "")
document.jj.total.value = ( parseInt(document.jj.total.value) + document.jj.T39.value * 299.01 );
else if (document.jj.total.value == null, document.jj.total.value == "")
document.jj.total.value = document.jj.total.value;
}

function grand4(){
if (document.jj.T27.value == null, document.jj.T27.value == "")
document.jj.total.value = ( parseInt(document.jj.total.value));
else if (document.jj.T27.value != null, document.jj.T27.value != "")
document.jj.total.value = ( parseInt(document.jj.total.value) + document.jj.T27.value * 99.95 );
else if (document.jj.total.value == null, document.jj.total.value == "")
document.jj.total.value = document.jj.total.value;
}

function grand5(){
if (document.jj.T39.value == null, document.jj.T39.value == "")
document.jj.total.value = ( parseInt(document.jj.total.value));
else if (document.jj.T39.value != null, document.jj.T39.value != "")
document.jj.total.value = ( parseInt(document.jj.total.value) + parseInt(document.jj.T39.value) * parseInt(document.jj.T40.value) );
else if (document.jj.total.value == null, document.jj.total.value == "")
document.jj.total.value = document.jj.total.value;
}
</SCRIPT>
</form>
</body>
</html>

gigabites
09-26-2004, 01:13 AM
Try this.. it's simpler :)

<input type="button" value="Add my total" name="B3" onclick="sum()"></td>

function sum()
{
var sum = 0;

if (document.jj.T10.value > 0)
sum += ( document.jj.T10.value * 399.01 );
if (document.jj.T9.value > 0)
sum += ( document.jj.T9.value * 49.95 );

if (document.jj.T8.value > 0)
{
var n1 = document.jj.T8.value;
if (n1 >= 1 && n1 <= 25)
sum += n1 * 12.95;
else if (n1 >= 26 && n1 <= 49)
sum += n1 * 9.95;
else if (n1 >= 50 && n1 <= 9000)
sum += n1 * 7.95;
}

if (document.jj.T25.value > 0)
sum += document.jj.T25.value * 7.95;
if (document.jj.T39.value > 0)
sum += document.jj.T39.value * 299.01;
if (document.jj.T27.value > 0)
sum += document.jj.T27.value * 99.95;

document.jj.total.value = sum;
}

Nate_Bro
09-26-2004, 05:31 AM
Thanks!! you are awesome!! just in time to, my dead line is by tomorrow, and i still have to do three more CGI scripts tonight, thanks so much!! you just saved me hours of frustration, and now i got a better idea how to use javascript, thanks, i'm still very new to this, thanks again, :)

gigabites
09-26-2004, 07:38 AM
Anytime Bro :)

Nate_Bro
09-27-2004, 07:39 AM
well got it all finished and works great!! thanks