I'm using the following JavaScript / HTML:
<select id="mySelect" onchange="myFunction()">
<option value="">Select
<option value="150">USA
<option value="50">Canada
<option value="200">UK
<option value="75">Kenya
</select>
<script>
simpleCart.shipping(function myFunction(){
var x = simpleCart.quantity();
var y = document.getElementById("mySelect").value;
if( x > 0 ){
return y * x;
} else {
return 0;
}
});
</script>
Currently, I can't call myFunction()
onchange
for some reason. What do I need to change so that I can call myFunction()
?
You could try wrapping the function like:
<script>
function myFunction() {
simpleCart.shipping(function(){
var x = simpleCart.quantity();
var y = document.getElementById("mySelect").value;
if( x > 0 ){
return y * x;
} else {
return 0;
}
});
}
</script>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.