1
I am doing a validation of 2 radios Buttons, where depending on which form is selected forwards to a different page. I am using Jquery as below:
jQuery(document).ready(function($) {
var form = $('form[name="cadastro"]'),
radio = $('input[name="MERCADO"]'),
choice = '';
radio.change(function(e) {
choice = this.value;
if (choice === "ME") {
form.attr('action', 'Checklist-P1-ME.php');
} else {
form.attr('action', 'Checklist-P1.php');
}
});
});
The radios are these:
<input type="radio" name="MERCADO" value="MI" CHECKED/>MERCADO INTERNO<br><br>
<input type="radio" name="MERCADO" value="ME" />MERCADO EXTERNO<br><br><br>
But what happens is that Jquery only recognizes the MI value if I click on the ME and then click back on the MI. It’s like it doesn’t recognize the checked
preset.
Any suggestions?
Why don’t you put default form action? depending on the input that starts checked? In this case the form action would start as
Checklist-P1.php
by default– Miguel
I can’t believe I asked a question with such a simple solution.... I left the action default and it worked.... thanks
– Diego
:P there is no problem in that, sometimes the obvious/simple solution passes us by
– Miguel