I am creating an online store kind of thing, in the backend you can specify product options, such as color, disk space etc etc..
On the frontend it outputs the options into a select box as below;
Expand|Select|Wrap|Line Numbers
- <select name="options" id="options" onchange="UpdateDisplay(this.options[this.selectedIndex].value)">
- <option value="0">-- Base Product --</option>
- <!-- Option Value = Option ID -->
- <option value="17">1.60GHz Intel Core 2 Duo (Included in price)</option>
- <option value="18">1.80GHz Intel Core 2 Duo (add € 296.89)</option>
- </select>
Expand|Select|Wrap|Line Numbers
- case (id = "<%=rs1("id_value")%>"):
- document.getElementById('checkout_button').innerHTML = '<input type="submit" name="buy" class="button-buy-big" alt="Buy" value="Buy" />';
- document.getElementById('store_price').innerHTML = parseInt(document.getElementById('store_price').innerHTML) + parseInt(<%=rs1("price_impact_amt")%>);
- document.getElementById('store_stock').innerHTML = '<img alt="In Stock" border="0" src="assets/images/template/theme_blue/icons/stocked.gif""> <%=Int(rs1("quantity"))%> stocked';
- break
The price is held in a <span> tag that looks like this;
Expand|Select|Wrap|Line Numbers
- <span id="store_price">1,799.00</span>
The main problem is that after it does this, it the user changes the option it will just append the new price onto the old total. which means the total still includes the option they just changed.
So to summarize, what i need to fix is;
- I need it so that when the user selects an option, it will add the option amount to the "store_pric e" price.
- I need it so when the user changes the option, it subtracts the original option amount and then appends the new one.
All help appreciated, i have spent way to much time trying to fix this..