I am newbie to javascript I trying to code conditions for currency change based on shipping country but getting error for all conditions.
Conditions
if the country is India and currency is Indian Rupees – Proceed to next page
if the country is India and currency is not India Rupees – alert as “Change currency as Indian Rupees”
if the country is not India and currency is India Rupees – alert as “Change currency as other than Indian Rupees”
if the country is not India and currency is not Indian Rupees – Proceed to next page
Help me to correct the error.
Thanks in advance.
[CODE]<div id=”navMainSearch” style=”height: 50px; margin-top: 18px; margin-bottom: -15px;”>
<form method=”get” action=”” name=”currencies”>
<select id=”money” onchange=”” name=”currency”>
<option value=”USD”>US Dollar</option>
<option value=”EUR”>Euro</option>
<option value=”GBP”>British Pound Sterling</option>
<option value=”CAD”>Canadian Dollar</option>
<option value=”AUD”>Australian Dollar</option>
<option value=”INR”>Indian Rupees</option>
</select>
<input type=”hidden” value=”checkout” name=”main_page”>
<input type=”hidden” name=”fecaction”>
</form>
</div>
<div id=”checkoutShipto” class=”floatingBox back”>
<address class=”checkoutAddress”>
Raja
<br>
423, Vinayagar Kovil Street
<br>
Chennai, 600027
<br>
TN,India<div id=”location”>India</div>
</address>
</div>
<div class=”buttonRow forward”>
<input type=”submit” onclick=”submitFunction()” title=”Confirm Order ” alt=”Confirm Order” value=”submit” act>
</div>
</div>
<script type=”text/javascript”>
function submitFunction() {
var country = document.getElementById(“location”).innerText;
var currency = document.getElementById(“money”).innerText;
if (country == ‘India’ && currency == ‘INR’) {
window.location.assign(“thanks.html”);
} else if (country == ‘India’ && currency != ‘INR’) {
alert(“Change the currency as Indian Rupee “);
} else if (country != ‘India’ && currency == ‘INR’) {
alert(“Change the currency as other than Indian Rupee “);
} else {
window.location.assign(“thanks.html “);
}
}
</script>