...

View Full Version : Adding total Item quantity for shipping



kona72
05-09-2006, 12:36 AM
Here is my form i have right now... I need it to take variable cc and multiply it by the total of variables a thru k for a total to be placed in aa.

I thought i had it; but no luck.... PLEASE HELP!!


<script language="javascript" type="text/javascript">
<!--
function calcprice(){

a = document.getElementById('POS_Qty');
b = document.getElementById('RGO_Qty');
c = document.getElementById('STR_Qty');
d = document.getElementById('WC_Qty');
e = document.getElementById('SS_Qty');
f = document.getElementById('SC_Qty');
g = document.getElementById('MH_Qty');
h = document.getElementById('FFT_Qty');
i = document.getElementById('SER_Qty');
j = document.getElementById('WL_Qty');
k = document.getElementById('REL_Qty');
m = document.getElementById('price');
n = document.getElementById('POS_Price');
o = document.getElementById('RGO_Price');
p = document.getElementById('STR_Price');
q = document.getElementById('WC_Price');
r = document.getElementById('SS_Price');
s = document.getElementById('SC_Price');
t = document.getElementById('MH_Price');
u = document.getElementById('FFT_Price');
v = document.getElementById('SER_Price');
w = document.getElementById('WL_Price');
x = document.getElementById('REL_Price');
aa = document.getElementById('sh');
bb = document.getElementById('total');
cc = document.getElementById('ship');

n.value = (parseInt(a.value) * parseFloat(m.value)).toFixed(2);
o.value = (parseInt(b.value) * parseFloat(m.value)).toFixed(2);
p.value = (parseInt(c.value) * parseFloat(m.value)).toFixed(2);
q.value = (parseInt(d.value) * parseFloat(m.value)).toFixed(2);
r.value = (parseInt(e.value) * parseFloat(m.value)).toFixed(2);
s.value = (parseInt(f.value) * parseFloat(m.value)).toFixed(2);
t.value = (parseInt(g.value) * parseFloat(m.value)).toFixed(2);
u.value = (parseInt(h.value) * parseFloat(m.value)).toFixed(2);
v.value = (parseInt(i.value) * parseFloat(m.value)).toFixed(2);
w.value = (parseInt(j.value) * parseFloat(m.value)).toFixed(2);
x.value = (parseInt(k.value) * parseFloat(m.value)).toFixed(2);
aa.value = (parseInt(cc.value) * parseFloat((a.value)+(b.value)+(c.value))).toFixed(2);

val1 = parseFloat(n.value);
val2 = parseFloat(o.value);
val3 = parseFloat(p.value);
val4 = parseFloat(q.value);
val5 = parseFloat(r.value);
val6 = parseFloat(s.value);
val7 = parseFloat(t.value);
val8 = parseFloat(u.value);
val9 = parseFloat(v.value);
val10 = parseFloat(w.value);
val11 = parseFloat(x.value);
val13 = parseFloat(aa.value);

st = eval(val1+val2+val3+val4+val5+val6+val7+val8+val9+val10+val11+val13);

bb.value = st.toFixed(2);

}

And here is the form.....



<table width="650" border="0">
<!--DWLayoutTable-->
<tr>
<td height="21" colspan="2" valign="bottom"><div align="right"><font size="1" face="Verdana, Arial, Helvetica, sans-serif">Please
rush me the following DVDs: </font></div></td>
<td width="47" valign="bottom"><div align="right"><font color="#000099" size="1" face="Verdana, Arial, Helvetica, sans-serif">&nbsp;Quantity</font></div></td>
<td width="42" valign="bottom"><div align="center"><font color="#000099" size="1" face="Verdana, Arial, Helvetica, sans-serif">Price</font></div></td>
<td width="252" valign="bottom"><div align="left"><font color="#003399" size="1" face="Verdana, Arial, Helvetica, sans-serif"><font color="#000000">DVDs
are $34.95 </font><font color="#000000" size="1" face="Verdana, Arial, Helvetica, sans-serif">each</font>
<font color="#000000">(US dollars) </font></font></div></td>
</tr>
<tr>
<td height="24" colspan="2" valign="middle"><div align="right"><font color="#000000" size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Positivity</strong></font></div></td>
<td valign="top" bgcolor="#FFFFFF"><div align="center"><font color="#003399" size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>
<input name="POS_Qty" type="text" id="POS_Qty" onBlur="calcprice()" value=" 0" size="4" maxlength="4">
</strong></font></div></td>
<td valign="top"><font color="#003399" size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>
<input name="POS_Price" type="text" id="POS_Price" size="7">
</strong></font></td>
<td valign="top"><input name="price" type="hidden" id="price" value="34.95">
<input name="ship" type="hidden" id="ship" value="5.00">
</td>
</tr>
<tr>
<td height="24" colspan="2" valign="middle"><div align="right"><font color="#000000" size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Relax
and Let Go</strong></font></div></td>
<td valign="top"><div align="center"><font color="#003399" size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>
<input name="RGO_Qty" type="text" id="RGO_Qty" onBlur="calcprice()" value=" 0" size="4" maxlength="4">
</strong></font></div></td>
<td valign="top"><font color="#003399" size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>
<input name="RGO_Price" type="text" id="RGO_Price" size="7" maxlength="7">
</strong></font></td>
<td valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
</tr>
<tr>
<td height="24" colspan="2" valign="middle"><div align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Stress
Control</strong></font></div></td>
<td valign="top"><div align="center">
<input name="STR_Qty" type="text" id="STR_Qty" onBlur="calcprice()" value=" 0" size="4" maxlength="4">
</div></td>
<td valign="top"><input name="STR_Price" type="text" id="STR_Price" size="7" maxlength="7"></td>
<td valign="top"><div align="right"><strong><font color="#FF0000" size="1" face="Verdana, Arial, Helvetica, sans-serif">TIP:<font color="#333333"> </font></font></strong><font color="#333333" size="1" face="Verdana, Arial, Helvetica, sans-serif">Use your <strong>Tab</strong> key to move<br>
through the fields</font></div></td>
</tr>
<tr>
<td height="24" colspan="2" valign="middle"><div align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Weight
Control</strong></font></div></td>
<td valign="top"><div align="center">
<input name="WC_Qty" type="text" id="WC_Qty" onBlur="calcprice()" value=" 0" size="4" maxlength="4">
</div></td>
<td valign="top"><input name="WC_Price" type="text" id="WC_Price" size="7" maxlength="7"></td>
<td valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
</tr>
<tr>
<td height="24" colspan="2" valign="middle"><div align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Stop
Smoking</strong></font></div></td>
<td valign="top"><div align="center">
<input name="SS_Qty" type="text" id="SS_Qty" onBlur="calcprice()" value=" 0" size="4" maxlength="4">
</div></td>
<td valign="top"><input name="SS_Price" type="text" id="SS_Price" size="7" maxlength="7"></td>
<td valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
</tr>
<tr>
<td height="24" colspan="2" valign="middle"><div align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Self
Confidence</strong></font></div></td>
<td valign="top"><div align="center">
<input name="SC_Qty" type="text" id="SC_Qty" onBlur="calcprice()" value=" 0" size="4" maxlength="4">
</div></td>
<td valign="top"><input name="SC_Price" type="text" id="SC_Price" size="7" maxlength="7"></td>
<td valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
</tr>
<tr>
<td height="24" colspan="2" valign="middle"><div align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Mind
and Hypnosis</strong></font></div></td>
<td valign="top"><div align="center">
<input name="MH_Qty" type="text" id="MH_Qty" onBlur="calcprice()" value=" 0" size="4" maxlength="4">
</div></td>
<td valign="top"><input name="MH_Price" type="text" id="MH_Price" size="7" maxlength="7"></td>
<td valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
</tr>
<tr>
<td height="24" colspan="2" valign="middle"><div align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Freedom
from Tranquilizers</strong></font></div></td>
<td valign="top"><div align="center">
<input name="FFT_Qty" type="text" id="FFT_Qty" onBlur="calcprice()" value=" 0" size="4" maxlength="4">
</div></td>
<td valign="top"><input name="FFT_Price" type="text" id="FFT_Price" size="7" maxlength="7"></td>
<td valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
</tr>
<tr valign="middle">
<td height="24" colspan="5"><div align="center"><font color="#000099" size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Psychovisual
Professional Series</em></strong></font></div></td>
</tr>
<tr>
<td height="24" colspan="2" valign="middle"><div align="right"><strong><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Serenity</font></strong></div></td>
<td valign="top"><div align="center">
<input name="SER_Qty" type="text" id="SER_Qty" onBlur="calcprice()" value=" 0" size="4" maxlength="4">
</div></td>
<td valign="top"><input name="SER_Price" type="text" id="SER_Price" size="7" maxlength="7"></td>
<td valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
</tr>
<tr>
<td height="24" colspan="2" valign="middle"><div align="right"><strong><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Weight
Loss</font></strong></div></td>
<td valign="top"><div align="center">
<input name="WL_Qty" type="text" id="WL_Qty" onBlur="calcprice()" value=" 0" size="4" maxlength="4">
</div></td>
<td valign="top"><input name="WL_Price" type="text" id="WL_Price" size="7" maxlength="7"></td>
<td valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
</tr>
<tr>
<td height="24" colspan="2" valign="middle"><div align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>Relaxation</strong></font></div></td>
<td valign="top"><div align="center">
<input name="REL_Qty" type="text" id="REL_Qty" onBlur="calcprice()" value=" 0" size="4" maxlength="4">
</div></td>
<td valign="top"><input name="REL_Price" type="text" id="REL_Price" size="7" maxlength="7"></td>
<td valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
</tr>
<tr>
<td height="24" colspan="3" valign="middle"><div align="right"><font size="2" face="Arial, Helvetica, sans-serif"></font></div>
<div align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Shipping &amp; Handling </font>
</div></td>
<td valign="top"><input name="sh" type="text" id="sh" value="5.00" size="7" maxlength="7"></td>
<td valign="middle"><font size="1" face="Verdana, Arial, Helvetica, sans-serif">($5 per DVD)</font></td>
</tr>
<tr>
<td height="24" colspan="3" valign="middle"><div align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><strong>TOTAL</strong></font></div></td>
<td valign="top"><input name="total" type="text" id="total" size="7" maxlength="7"></td>
<td valign="middle"><!--DWLayoutEmptyCell-->&nbsp;</td>
</tr>
<tr>
<td height="26" colspan="2" valign="top"><div align="right">
<input name="Reset" type="reset" id="Reset" onClick="MM_validateForm('RGO_Qty','','NisNum','STR_Qty','','NisNum','WC_Qty','','NisNum','SS_Qty','','NisNum ');return document.MM_returnValue" value="Reset">
</div></td>
<td colspan="2" valign="top"> <input type="submit" name="Submit" value="Submit"> </td>
<td valign="top"><div align="right"><font color="#333333" size="1" face="Verdana, Arial, Helvetica, sans-serif">This is your receipt.<br>
Please print out a copy for your records.</font></div></td>
</tr>
<tr>
<td width="205" height="4"></td>
<td width="82"></td>
<td></td>
<td></td>
<td></td>
</tr>
</table>
</div>
<input type="hidden" name="MM_insert" value="Confidential_Psychovisual_OrderForm">
</form>
<h5 align="center"><a href="index.htm"><font face="Verdana, Arial, Helvetica, sans-serif">Back to main page </font></a></h5></td>

<tr>
<td height="1"></td>
</table>

bigtiger
05-09-2006, 01:21 AM
hi, I'am not sure what you want to do, just guess it, I think you can use an array and for loop to do the job.

Hope this help :)

kona72
05-09-2006, 05:13 PM
This is driving me nuts...
I was up til 2 last night trying to figure this out. Please see first post for code... Here is a link to the page as i have it right now...

http://www.psychovisual.com/DVD_order_form1.php (http://www.psychovisual.com/DVD_order_form1.php)

The page is stripped of the mail and database functions until i get it figured out...



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum