I'm creating an online diary app using PHP MySQL and jQuery. Exciting times.
The problem I've run into is setting the state of a set of Radio buttons which determines how often an event recurs (if at all).
So I have three radio buttons like so:
<input type="radio" name="recur" id="never" value="X" checked>
<input type="radio" name="recur" id="weekly" value="W">
<input type="radio" name="recur" id="monthly" value="M">
This is fine for adding a new event, but I am also using the same form to edit an event. When it is in 'edit mode', the fields of the form are populated by an ajax call. This includes a hidden input .recurrence which is populated 'X', 'W', or 'M'.
What I want to do is something like:
var recurrence = $('#events .selected .recurrence').val();
case 'M': $('#monthly').checked = true;
case 'W': $('#weekly').checked = true;
default: $('#never').checked = true;
Which bizarrely will work when the event is monthly, but not when the event is weekly or never.
Also I can't seem to reset the radio buttons, when I clear the form later in my script.
Any help greatly received,
Please be aware, this actually works fine. Dunno what happened on that day, but the code above works fine now.