DakotaChick
12-03-2007, 05:21 AM
Hi guys,
I need some help converting this VBScript over to JavaScript so that the calculations will work properly in browsers other than IE.
You can take a look at Turn 2 Design (http://turn2designsc.com/quote.asp) for a feel about what I'm trying to do, but basicly, I just need to calculate the cost of the selected items based on the selected quantity of that item.
The only thing I know about JavaScript is the small Pop-up scripts I've been able to litterally copy and paste to implement. So, please, dont just post code, post an explaination of whats going on and why so I can try to figure it out.
The VBScript Code:
(I didnt include all of the product functions since they are all exactly the same as the posted on, only different names)
<script language="vbscript">
sub Window_OnLoad()
totalCost()
end sub
<!-----------Total Cost Function----------->
sub totalCost()
totals = 25
totals = totals + document.quote.BW1Price.value
totals = totals + document.quote.CS18Price.value
totals = totals + document.quote.CM15Price.value
totals = totals + document.quote.CM11Price.value
totals = totals + document.quote.TM14Price.value
totals = totals + document.quote.CB1Price.value
totals = totals + document.quote.MP1Price.value
totals = totals + document.quote.ST1Price.value
totals = totals + document.quote.TSSLCLGPrice.value
totals = totals + document.quote.TSSWLGPrice.value
totals = totals + document.quote.TSSLCPrice.value
totals = totals + document.quote.TSSWPrice.value
totals = totals + document.quote.LP2Price.value
totals = totals + document.quote.LP1Price.value
document.quote.Total.value = formatcurrency(totals)
end sub
<!-----------Product Function----------->
sub CalcBW1()
num = document.quote.BW1Qty.value * 4.75
document.quote.BW1Price.value = num
totalCost()
end sub
</script>
The HTML Form Code:
<form id="quote" name="quote" method="post" action="quote-ac.asp">
<table width="40%" border="0" align="center" cellpadding="5" cellspacing="2">
<tr>
<td width="8%"> </td>
<td width="69%" class="BodyText"><div align="left">Graphic Set Up</div></td>
<td width="23%" class="BodyText"><div align="left">Required</div></td>
</tr>
<tr>
<td>
<a href="javascript:poptastic('19');">
<img src="images/art021.gif" width="15" height="15" border="0" /> </a>
</td>
<td class="BodyText"><div align="left">
<input name="BW1" type="text" class="Quote1" id="BW1" readonly="readonly" value="Beverage Wrap" /></div></td>
<td class="BodyText">
<div align="left">
<select name="BW1Qty" id="BW1Qty" onchange="CalcBW1()">
<option value="0" selected="selected">0</option>
<option value="10">10</option>
<option value="20">20</option>
<option value="50">50</option>
<option value="100">100</option>
</select>
<input type="hidden" name="BW1Price" id="BW1Price" value="0" />
</div>
</td>
</tr>
<!-- More Items Here, but code is exactly the same as the above textbox, select box, and hidden box -->
<tr>
<td> </td>
<td class="BodyText"><div align="right"><strong>Total:</strong></div></td>
<td class="BodyText"><div align="left">
<input name="Total" type="text" class="Quote" id="Total" size="10" readonly="readonly" />
</div></td>
</tr>
<tr>
<td colspan="3"><div align="right">
<input name="button" type="submit" class="Buttons" id="button" value="Request Appt" />
</div></td>
</tr>
</table>
</form>
I need some help converting this VBScript over to JavaScript so that the calculations will work properly in browsers other than IE.
You can take a look at Turn 2 Design (http://turn2designsc.com/quote.asp) for a feel about what I'm trying to do, but basicly, I just need to calculate the cost of the selected items based on the selected quantity of that item.
The only thing I know about JavaScript is the small Pop-up scripts I've been able to litterally copy and paste to implement. So, please, dont just post code, post an explaination of whats going on and why so I can try to figure it out.
The VBScript Code:
(I didnt include all of the product functions since they are all exactly the same as the posted on, only different names)
<script language="vbscript">
sub Window_OnLoad()
totalCost()
end sub
<!-----------Total Cost Function----------->
sub totalCost()
totals = 25
totals = totals + document.quote.BW1Price.value
totals = totals + document.quote.CS18Price.value
totals = totals + document.quote.CM15Price.value
totals = totals + document.quote.CM11Price.value
totals = totals + document.quote.TM14Price.value
totals = totals + document.quote.CB1Price.value
totals = totals + document.quote.MP1Price.value
totals = totals + document.quote.ST1Price.value
totals = totals + document.quote.TSSLCLGPrice.value
totals = totals + document.quote.TSSWLGPrice.value
totals = totals + document.quote.TSSLCPrice.value
totals = totals + document.quote.TSSWPrice.value
totals = totals + document.quote.LP2Price.value
totals = totals + document.quote.LP1Price.value
document.quote.Total.value = formatcurrency(totals)
end sub
<!-----------Product Function----------->
sub CalcBW1()
num = document.quote.BW1Qty.value * 4.75
document.quote.BW1Price.value = num
totalCost()
end sub
</script>
The HTML Form Code:
<form id="quote" name="quote" method="post" action="quote-ac.asp">
<table width="40%" border="0" align="center" cellpadding="5" cellspacing="2">
<tr>
<td width="8%"> </td>
<td width="69%" class="BodyText"><div align="left">Graphic Set Up</div></td>
<td width="23%" class="BodyText"><div align="left">Required</div></td>
</tr>
<tr>
<td>
<a href="javascript:poptastic('19');">
<img src="images/art021.gif" width="15" height="15" border="0" /> </a>
</td>
<td class="BodyText"><div align="left">
<input name="BW1" type="text" class="Quote1" id="BW1" readonly="readonly" value="Beverage Wrap" /></div></td>
<td class="BodyText">
<div align="left">
<select name="BW1Qty" id="BW1Qty" onchange="CalcBW1()">
<option value="0" selected="selected">0</option>
<option value="10">10</option>
<option value="20">20</option>
<option value="50">50</option>
<option value="100">100</option>
</select>
<input type="hidden" name="BW1Price" id="BW1Price" value="0" />
</div>
</td>
</tr>
<!-- More Items Here, but code is exactly the same as the above textbox, select box, and hidden box -->
<tr>
<td> </td>
<td class="BodyText"><div align="right"><strong>Total:</strong></div></td>
<td class="BodyText"><div align="left">
<input name="Total" type="text" class="Quote" id="Total" size="10" readonly="readonly" />
</div></td>
</tr>
<tr>
<td colspan="3"><div align="right">
<input name="button" type="submit" class="Buttons" id="button" value="Request Appt" />
</div></td>
</tr>
</table>
</form>