function below will output price value in text field based on drop-menu option. It’s working but I want it’s always show value in 2 decimal point. Can anyone help me with this problem?
function findPrice() {
if (document.getElementById(“region”).value == “blank”) {
var price = document.getElementById(“price”);
price.value = “<?php echo ‘Choose your region to get the price’; ?>”;
}
if (document.getElementById(“region”).value == “Peninsular Malaysia”) {
var price = document.getElementById(“price”).value = “$” + price.toFixed(2);;
price.value= ‘<?php echo $PM_Price; ?>’;
}
if (document.getElementById(“region”).value == “Sabah/Labuan”) {
var price = document.getElementById(“price”);
price.value = ‘<?php echo $SL_Price; ?>’;
}
if (document.getElementById(“region”).value == “Sarawak”) {
var price = document.getElementById(“price”);
price.value = ‘<?php echo $SR_Price; ?>’;
}
}
Actually my script was like this. This script nothing doing with decimal point. What I should do to make the price value will be shown in decimal points?
function findPrice() {
if (document.getElementById(“region”).value == “blank”) {
var price = document.getElementById(“price”);
price.value = “<?php echo ‘Choose your region to get the price’; ?>”;
}
if (document.getElementById(“region”).value == “Peninsular Malaysia”) {
var price = document.getElementById(“price”);
price.value= ‘<?php echo $PM_Price; ?>’;
}
if (document.getElementById(“region”).value == “Sabah/Labuan”) {
var price = document.getElementById(“price”);
price.value = ‘<?php echo $SL_Price; ?>’;
}
if (document.getElementById(“region”).value == “Sarawak”) {
var price = document.getElementById(“price”);
price.value = ‘<?php echo $SR_Price; ?>’;
}
}