1

I designed my mobile application using Codiqa. So all css and js are loading from the link. I don't know how to uncheck all radio buttons in a radiobutton list. I tried many coding but its not working for me. HTML:

       <div data-role="fieldcontain" data-controltype="radiobuttons">
          <fieldset data-role="controlgroup" data-type="vertical">
              <legend>
                  Shift
              </legend>
              <input id="radio1" name="rbtnShift" value="1" data-theme="c" type="radio">
              <label for="radio1">
                  AM
              </label>
              <input id="radio2" name="rbtnShift" value="2" data-theme="c" type="radio">
              <label for="radio2">
                  PM
              </label>
              <input id="radio3" name="rbtnShift" value="3" data-theme="c" type="radio">
              <label for="radio3">
                  Night
              </label>
          </fieldset>
      </div>

Jquery:

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

I tried above coding but its not working for me. I'm certainly missing something basic, but I can't figure out what is the problem.

First, I select a option

enter image description here

After button click, it showing the same like given below

enter image description here

Andrew Barber
  • 39,603
  • 20
  • 94
  • 123

3 Answers3

4

You can give them a classname and try:

$('.classname').prop('checked', false);
Kanishka Panamaldeniya
  • 17,302
  • 31
  • 123
  • 193
  • Hi kanishka, thanks for your reply. This is a mobile application so its designed in Codiqa. The class and js are dynamically loading from the link. I tried this also. but its not working for me. –  Aug 15 '13 at 04:51
2

Using knockout.js, below code for unselect all radio buttons in a list

 $("input[type='radio']").checkboxradio();         
 $("input[name^='rbtnShift']").attr("checked", false).checkboxradio("refresh");

Use below code for dynamically selecting a radio buttons in a list,

$("input[type='radio']").checkboxradio();           
$("input[name=rbtnShift][value=" + 1 + "]").prop('checked', true);
$("input[name^='rbtnShift']").attr("checked", true).checkboxradio("refresh");
0

You may try this also;

$('input:radio[name="rbtnShift"]').removeAttr('checked');
Firnas
  • 1,665
  • 4
  • 21
  • 31
  • Hi firnas, its also not working for me. I don't know why all the codes are not working for me? –  Aug 15 '13 at 04:53
  • If there is no error, then there is nothing wrong in your code. However, there might be another code that does this purposely. Try to trigger and see where it happens, may be you can debug. – Firnas Aug 15 '13 at 05:20