PDA

View Full Version : Improved Order Form HELP Part II



cardnexus
09-19-2006, 09:22 PM
I tried to mod the select menu to radio button for this order form. However, instead showing the value I assgined, it displays an error message.
Can anybody help me with this?


<HTML>
<HEAD>

<TITLE>Quick Computer System Price By David Ng dng606@email.com</TITLE>


<SCRIPT LANGUAGE="JavaScript">

function ComputeTotal( form )
{
//Profit calculator
//
Profit_rate1 = 1 + 0.12 // change the profit %
// ^^
Profit_rate2 = 1 + 0.10 // change the profit %
// ^^
Profit_rate3 = 1 + 0.11 // change the profit %
// ^^
Profit_rate4 = 1 + 0.20 // change the profit %
// ^^
Profit_rate5 = 1 + 0.07 // change the profit %
// ^^
CPU = form.CPU1.value = round(form.CPU.value * Profit_rate1)
MAB = form.Mainboard1.value = round(form.Mainboard.value*Profit_rate2)


subtotal1 = CPU + MAB

form.subtotal1.value = subtotal1

savevalue = round(form.subtotal1.value * form.disrate.value)

subt2 = form.subtotal2.value = form.subtotal1.value - savevalue

tax1 = form.tax.value = round(form.subtotal2.value / 100 * form.taxrate.value)

form.total.value = round(subt2 + tax1)

}

function round(number,X) {
// rounds number to X decimal places, defaults to 2
X = (!X ? 2 : X);
return Math.round(number*Math.pow(10,X))/Math.pow(10,X);

}


</SCRIPT>
</HEAD>

<BODY BGCOLOR="#F8F8FF">

<FORM
METHOD="POST"
ACTION="mailto:email@address.com?subject=Computer System">
<table width="591" border="1">
<tr>
<td width="535">

<input type="radio" value=30 name="CPU" onClick="ComputeTotal(this.form)">
<input type="radio" value=40 name="CPU" onClick="ComputeTotal(this.form)">
<input type="radio" value=50 name="CPU" onClick="ComputeTotal(this.form)">

</td>
<td width="40">
<input type="TEXT" size=6 name="CPU1" maxlength="6">
</td>
</tr>
<tr>
<td width="535">
<select name="Mainboard" onChange="ComputeTotal(this.form)">
<option value="0">Select a Mainboard</option>
<option value="98">ABIT Intel® 440BX Slot1 ATX</option>
<option value="82">Asus Intel® 440BX Slot1 ATX</option>
<option value="165">Asus Intel® 440BX Dual Slot1 ATX</option>
<option value="240">Asus Intel® 440BX Dual Slot1 SCSI ATX</option>
<option value="80">EPoX Intel® 440BX Slot1 ATX</option>
<option value="160">EPoX Intel® 440BX Dual Slot1 ATX</option>
<option value="90">SuperMicro Intel® 440BX Slot1 ATX</option>
<option value="170">SuperMicro Intel® 440BX Dual Slot1 ATX</option>
<option value="245">SuperMicro Intel® 440BX Dual Slot1 SCSI ATX</option>
<option value="98">ABIT Intel® 440BX PPGA ATX</option>
<option value="140">ABIT Intel® 440BX Dual PPGA ATX</option>
<option value="82">Asus Intel® 440BX PPGA ATX</option>
<option value="80">EPoX Intel® 440BX PPGA ATX</option>
<option value="89">SuperMicro Intel® 440BX PPGA ATX</option>
<option value="82">Asus Intel® 440BX PPGA ATX</option>
<option value="80">EPoX Intel® 440BX PPGA ATX</option>
<option value="85">SuperMicro Intel® 440BX PPGA Slot1 ATX</option>
<option value="82">Asus ALI Socket7 ATX</option>
<option value="80">EPoX VIA MVP3 Socket7 ATX</option>
</select>
</td>
<td width="40">
<input type="TEXT" size=6 name="Mainboard1" maxlength="6">
</td>
</tr>




<tr>
<td width="535">
<p align="right"> <b>SUBTOTAL1: </b>
</td>
<td width="40"><b>
<input type="TEXT" size=6 name="subtotal1" maxlength="6">
</b></td>
</tr>
<tr>
<td width="535">
<p align="right">
<p align="right"><b>Discount Rate: </b>
<select name="disrate" onChange="ComputeTotal(this.form)">
<option value="0">0</option>
<option value="0.01">1</option>
<option value="0.02">2</option>
<option value="0.03">3</option>
<option value="0.04">4</option>
<option value="0.05">5</option>
<option value="0.06">6</option>
<option value="0.07">7</option>
<option value="0.08">8</option>
<option value="0.09">9</option>
<option value="0.10">10</option>
</select>
<b>SUBTOTAL2:</b>
</td>
<td width="40">
<input type="number" size=6 name="subtotal2" maxlength="6">
</td>
</tr>
<tr>
<td width="535">
<div align="right"><b>TAX:</b><input type="number" size=3 name="taxrate" value="8.25"></div>
</td>
<td width="40">
<input type="number" size=6 name="tax" maxlength="6">
</td>
</tr>
<tr>
<td width="535">
<p align="right">
<p align="right"><b>Total: </b></p>
</td>
<td width="40">
<input type="number" size=6 name="total" maxlength="6">
</td>
</tr>
</table>
<p>&nbsp;</p>

<input type="button" value="Go" onClick="window.location.href = 'cart2v1.htm?' + this.form.total.value">
</form></BODY></HTML>


<!-- Simba says Roar. -->

boogyman
09-20-2006, 08:32 AM
u need to name the form

codeexploiter
09-20-2006, 08:43 AM
Posted by pissa

u need to name the form


Yes but it is not mandatory, you still can access the form fields using the following method

document.forms[number].elements[number]


document.forms[0].text.value = 'The new value';

If you name the form yes there won't be any confusion you can access the form directly using its name.

cardnexus
09-20-2006, 04:20 PM
I added two For statements and the form name [] and it is still not working.
I can't really figure out why.

Can anybody help me?:confused:

Thank you!

<HTML>
<HEAD>

<TITLE>Quick Computer System Price By David Ng dng606@email.com</TITLE>


<SCRIPT LANGUAGE="JavaScript">

function ComputeTotal( form )
{
//Profit calculator
//
Profit_rate1 = 1 + 0.12 // change the profit %
// ^^
Profit_rate2 = 1 + 0.10 // change the profit %
// ^^
Profit_rate3 = 1 + 0.11 // change the profit %
// ^^
Profit_rate4 = 1 + 0.20 // change the profit %
// ^^
Profit_rate5 = 1 + 0.07 // change the profit %
// ^^


for(i=0;i<3;i++){
if(document.forms[0].CPU[i].checked){
CPU = form.CPU1.value = round(form.CPU[i].value*Profit_rate1);


for(k=0;k<3;k++){
if(document.forms[0].Mainboard[k].checked){
MAB = form.Mainboard1.value = round(form.Mainboard[k].value*Profit_rate2);

}
}


subtotal1 = CPU + MAB

form.subtotal1.value = subtotal1

savevalue = round(form.subtotal1.value * form.disrate.value)

subt2 = form.subtotal2.value = form.subtotal1.value - savevalue

tax1 = form.tax.value = round(form.subtotal2.value / 100 * form.taxrate.value)

form.total.value = round(subt2 + tax1)

}

function round(number,X) {
// rounds number to X decimal places, defaults to 2
X = (!X ? 2 : X);
return Math.round(number*Math.pow(10,X))/Math.pow(10,X);

}


</SCRIPT>
</HEAD>

<BODY BGCOLOR="#F8F8FF">

<FORM
METHOD="POST"
ACTION="mailto:email@address.com?subject=Computer System">
<table width="591" border="1">
<tr>
<td width="535">

<input type="radio" value=30 name="CPU" onClick="ComputeTotal(this.form)">
<input type="radio" value=40 name="CPU" onClick="ComputeTotal(this.form)">
<input type="radio" value=50 name="CPU" onClick="ComputeTotal(this.form)">

</td>
<td width="40">
<input type="TEXT" size=6 name="CPU1" maxlength="6">
</td>
</tr>
<tr>
<td width="535">



<input type="radio" value=30 name="Mainboard" onClick="ComputeTotal(this.form)">
<input type="radio" value=40 name="Mainboard" onClick="ComputeTotal(this.form)">
<input type="radio" value=50 name="Mainboard" onClick="ComputeTotal(this.form)">

</td>
<td width="40">
<input type="TEXT" size=6 name="Mainboard1" maxlength="6">
</td>
</tr>




<tr>
<td width="535">
<p align="right"> <b>SUBTOTAL1: </b>
</td>
<td width="40"><b>
<input type="TEXT" size=6 name="subtotal1" maxlength="6">
</b></td>
</tr>
<tr>
<td width="535">
<p align="right">
<p align="right"><b>Discount Rate: </b>
<select name="disrate" onChange="ComputeTotal(this.form)">
<option value="0">0</option>
<option value="0.01">1</option>
<option value="0.02">2</option>
<option value="0.03">3</option>
<option value="0.04">4</option>
<option value="0.05">5</option>
<option value="0.06">6</option>
<option value="0.07">7</option>
<option value="0.08">8</option>
<option value="0.09">9</option>
<option value="0.10">10</option>
</select>
<b>SUBTOTAL2:</b>
</td>
<td width="40">
<input type="number" size=6 name="subtotal2" maxlength="6">
</td>
</tr>
<tr>
<td width="535">
<div align="right"><b>TAX:</b><input type="number" size=3 name="taxrate" value="8.25"></div>
</td>
<td width="40">
<input type="number" size=6 name="tax" maxlength="6">
</td>
</tr>
<tr>
<td width="535">
<p align="right">
<p align="right"><b>Total: </b></p>
</td>
<td width="40">
<input type="number" size=6 name="total" maxlength="6">
</td>
</tr>
</table>
<p>&nbsp;</p>

<input type="button" value="Go" onClick="window.location.href = 'cart2v1.htm?' + this.form.total.value">
</form></BODY></HTML>