NameSilo

Drop-down box

Spaceship Spaceship
Watch
Impact
0
Hi all
I am building a website and have run into a problem with drop-down boxes
example: on my website I am selling a ring price $50 with this ring on the purchase page I have a drop-down box with ring sizes (10 Sizes) each size has an alternative price ie
size 1 +$1.99
size 2 +$2.99
size 3 +$3.99 and so on. My question: If a customer selects size 2 +$2.99
how can i get the additional price to add to the $50 on the checkout page. Is there a HTML code i can use or has anybody got an alternative solution for me.

best regards.
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
Unstoppable DomainsUnstoppable Domains
If you can add any value to the cart instead of your cart only reading default prices, you could alter fields in a HTML form based on selection and pass the values as the price.

HTML:
<!-- @value amount to add to base price -->
<select id="ringSize" onChange="modifyPrice()">
    <option value="0">Select Size</option>
    <option value="1.99">Size 1 + $1.99</option>
    <option value="2.99">Size 2 + $2.99</option>
    <option value="3.99">Size 3 + $3.99</option>
</select>


<!-- if sending via HTML form include this field
	@value current value of item to add to cart -->
<input type="hidden" value="50" id="totalValue" />


<!-- @value base price of item -->
<input type="hidden" value="50" id="basePrice" />

<!-- @span initially base price of item -->
<p>Current Price: $<span id="currentPrice">50</span></p>

<script language="JavaScript">

function modifyPrice(){
	var add = parseFloat(document.getElementById("ringSize").value);
	var base = parseFloat(document.getElementById("basePrice").value);
	var price = document.getElementById("currentPrice");
	var newPrice = add+base;
	price.innerHTML = newPrice;
}

</script>

Another alternative would be to add a field which is 'additionalCosts' on your server side script and take the value of the select field there to store the additionalCost in the cart, then simply add this at the end of your cart as an extra item before totalling the price.

It depends entirely on how you have built the cart, using fixed prices from a database, or taking the price provided by a form.
 
0
•••
StormNine thanks very much I will give it a go.
 
0
•••
Appraise.net

We're social

Unstoppable Domains
Domain Recover
NameMaxi - Your Domain Has Buyers
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back