I have some joomla articles to display my prices table. I need several articles to display several prices (for simple coupon system).
So I have my main price articles with a COUPON field form.
Code: Select all
<form class="form-inline" name="myForm" action="/index.php?option=com_content&view=article&id=15&Itemid=229"
onsubmit="return validateForm()" method="post">
<label for="fname">Code Promo:</label>
<input type="text" name="fname" value="PROMO2018">
<input class="btn btn-success" type="submit" value="Valider ce code">
</form>
Code: Select all
<script>
function validateForm() {
var x = document.forms["myForm"]["fname"].value;
if (x != "PROMO2018") {
alert("Le code PROMO n'est pas bon. Désolé. :-( ");
return false;
}
}
</script>
I would like now to work with several coupons. In fact, I need a 2nd one for another discount. So it will redirect to another joomla article prices with other prices.
So I wrote this javascript:
Code: Select all
<script>
function validateForm() {
var x = document.forms["myForm"]["fname"].value;
if (x == "PROMO2018") {
document = "index.php?option=com_rsform&view=rsform&formId=8&Itemid=484";
}
else
{
if (x == "ETUDIANTBDX")
{
location = "index.php?option=com_rsform&view=rsform&formId=4&Itemid=232";
}
else
{
alert("Le code PROMO n'est pas bon! Veuillez essayer un autre svp.");
return false;
}
}
}
</script>
Does anyone can tell me why user is not redirected to appropriate page when submiting coupon form.
THanks for your help.