By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,568 Members | 1,194 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,568 IT Pros & Developers. It's quick & easy.

Online Store - Product Options, Updating Prices

P: 13
Hi All,

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
  1. <select name="options" id="options" onchange="UpdateDisplay(this.options[this.selectedIndex].value)"> 
  2.   <option value="0">-- Base Product --</option>
  3. <!-- Option Value = Option ID -->
  4.   <option value="17">1.60GHz Intel Core 2 Duo (Included in price)</option>
  5.   <option value="18">1.80GHz Intel Core 2 Duo (add &euro; 296.89)</option>
  6. </select>                    
The onchange event triggers the script below;

Expand|Select|Wrap|Line Numbers
  1. case (id = "<%=rs1("id_value")%>"):
  2.  document.getElementById('checkout_button').innerHTML = '<input type="submit" name="buy" class="button-buy-big" alt="Buy" value="Buy" />';
  3.  document.getElementById('store_price').innerHTML = parseInt(document.getElementById('store_price').innerHTML) + parseInt(<%=rs1("price_impact_amt")%>);
  4.  document.getElementById('store_stock').innerHTML = '<img alt="In Stock" border="0" src="assets/images/template/theme_blue/icons/stocked.gif""> <%=Int(rs1("quantity"))%> stocked';
  5. break
The above javascript, changes the checkout button (disables it if out of stock for that option), if its not out of stock it updates the quantity and updates the price.

The price is held in a <span> tag that looks like this;
Expand|Select|Wrap|Line Numbers
  1. <span id="store_price">1,799.00</span>
The problem is, when i select the option it firstly does not append the original price, instead of running 1,799.00 + Option Amount it just appends Option Amount.

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_price" 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..
Aug 8 '08 #1
Share this Question
Share on Google+
2 Replies

P: 13
Anybody wanna give this a try?
Aug 9 '08 #2

P: 13
Nevermind, i got this problem solved. If anyone else is having this problem, i just edited the source code of the below example;
Aug 9 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.