...

View Full Version : price calculator w/ two dropdown menus



GoldDog
05-21-2005, 02:02 AM
The pricing calculator I am building into this form is dependent upon two menu choices. Using the following function I had it working beautifully for one dropdown (#price# is ColdFusion's way of saying, this product's value):


function reCalc() {
si = document.eForm.qty.selectedIndex;
v = si*#price#+#price#;
document.getElementById('subT').innerHTML = v;
}

Using this menu (<cfloop> is ColdFusion's way of saying print 20 <option> statements.):


<select name="qty" onchange="reCalc()">
<cfloop index="i" from="1" to="20" step="1">
<option> #i#</cfloop>
</select>

But I need to add a second menu to this mix (here <cfoutput> is how ColdFusion loops through a query result set to display, in this case, product titles with associated prices):


<select name="type" onchange="reCalc()">
<cfoutput query="addon" group="title">
<option value="#price#"> #title#</cfoutput>
</select>

The value of "subT" needs to be adjusted each time either menu value is changed. My attempt to alter the function like so...


function reCalc() {
si = document.eForm.qty.selectedIndex;
ti = document.eForm.type.selectedIndex;
v = si*ti+ti;
document.getElementById('subT').innerHTML = v;
}

...did not work. What am I doing wrong?

Frustrated and grateful,
GD



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum