I am using simpleCart js. I would like to have the checkout button and shipping cost hidden until the customer selects UK or Rest of World. Here is the select block:
<select id="shippingSelect" onchange="simpleCart.update();">
<option value="nothing" selected="selected">Choose Shipping Location</option>
<option value="uk">UK</option>
<option value="world">Rest of World</option>
</select>
Under that is the shipping cost and checkout button:
<div class="place_order" style="display:none">
<span id="simpleCart_shipping" class="simpleCart_shipping"></span>
<a href="javascript:;" class="simpleCart_checkout btnDownload">checkout</a>
</div>
The simpleCart script that generates the cart:
<script>
simpleCart({
cartColumns: [
{ attr: "name" , label: "Item" },
{ view: "decrement" , label: false , text: "-" },
{ attr: "quantity", label: "Quantity", view: "input"},
{ view: "increment" , label: false , text: "+" },
{ attr: "price", label: "Price"},
{ attr: "total" , label: "Subtotal", view: "currency" }
],
cartStyle: "table",
currency: "GBP",
language: "english-us",
checkout: {
type: "PayPal" ,
email: "email@ddress",
success: "success.html"
},
shippingCustom: function(){
if( $("#shippingSelect").val() == "uk" ){
return 0;
} else {
return 2;
}
}
});
</script>
I thought I could use $('.place_order').css('display', 'inline'); to change the inline style but I don’t know how to do it, whether to incorporate it into the simpleCart script or have it trigger a separate script? Perhaps there is a more efficient way? Thanks!
Is this what you mean?
AFAIK it is bad practice to have spaces in class/id names.
It would be better in my opinion to disable/enable the button instead of hiding or showing it.