0

I've tried several ways of deselecting all elements in a radio button field, none of them have worked. I've read so many stackoverflow posts, and so much documentation. I must be so close, but I cannot figure out what I'm doing wrong

My goal is to clear the input field (this happens when a user clicks submit on the form). I can get text fields to clear, but the radio button selection just won't go away.

#addBudgetElement
    h2#addBudgetElementHeader Add to your budget
    fieldset
        input#inputBudgetElementName(type='text', placeholder="Title")
        br
        input#inputAmount(type='text', placeholder='Amount')
        br
        input(type="radio", name="frequency", value="Once")
        | Once
        input(type="radio", name="frequency", value="Daily")
        | Daily
        input(type="radio", name="frequency", value="Weekly")
        | Weekly
        input(type="radio", name="frequency", value="Monthly")
        | Monthly
        input(type="radio", name="frequency", value="Annually")
        | Anually
        br

        button(id='btnBudgetElementAction', data-action='add') Add To Budget
        button#btnCancelUpdate.hidden Cancel

I tried doing:

$('#addBudgetElement fieldset input:radio[name="frequency"]').prop('checked', false);

Source

and

$('#addBudgetElement fieldset input:radio[name="frequency"]').prop('checked', false).checkboxradio("refresh");

and

$("#addBudgetElement fieldset input:radio[name='frequency']").each(function(i) {
    this.checked = false;
});

and

$("#addBudgetElement fieldset input:radio:checked").removeAttr("checked");

Could anyone tell me what I'm doing wrong?

Community
  • 1
  • 1
Mike
  • 159
  • 3
  • 13
  • http://stackoverflow.com/questions/17120576/how-to-uncheck-checked-radio-button – Ivan Sivak Jan 14 '15 at 14:44
  • Can you add formatted HTML? All your tags are missing. – iCollect.it Ltd Jan 14 '15 at 14:44
  • all I can imagine is your selector not working... when you type this selector in your console, do you get the controls back or nothing ? – Laurent S. Jan 14 '15 at 14:46
  • When I put '$('#addBudgetElement fieldset input:radio[name="frequency"]')' in the console, I got back: [​, ​, ​, ​, ​]. There is no 'checked' or 'unchecked' property ever. Is this the correct behavior? – Mike Jan 14 '15 at 14:53

0 Answers0