Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8573125
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:10:45+00:00 2026-06-11T19:10:45+00:00

I have a database in which I get value 0 or 1 (No/Yes respectively).

  • 0

I have a database in which I get value 0 or 1 (No/Yes respectively).
How do I check/uncheck radio button and check its state in jQuery Mobile.
My code is below

HTML code

<label>Are you Mad? </label>   
 <fieldset data-role="controlgroup" data-type="horizontal">     
 <input data-mini="true" type="radio" name="rdIsBP" id="rdIsBPYes" value="" />
 <label for="rdIsBPYes">YES</label>
 <input data-mini="true"  type="radio" name="rdIsBP" id="rdIsBPNo" value="choice-1"  />
 <label for="rdIsBPNo">NO</label>
</fieldset>

JavaScript code

function  CheckRadioStateYNoo(val,rdButton){      
      try{
      var radios = document.getElementsByName(rdButton);
      for( i = 0; i < radios.length; i++ ) {
       if(i==0)
       {
          if(val==1) 
          {
              //radios[i].checked=true;
              $("#" + rdButton + "Yes").attr ("checked", "checked");
              alert('rdButton' +   radios[i].checked);               
          }          
      }
       else{
           if(val==1) 
           {
               radios[i].checked=true;
               alert('rdButton' +  radios[i].checked);               
           }
       }
      }
      }
      catch(e){alert(e);}
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T19:10:47+00:00Added an answer on June 11, 2026 at 7:10 pm

    i tried many experiments only this code is working for me
    val can be 0 for unchceck and 1 for checked in db.maybe some one find it useful

    html code

    <label> Have you had surgery within the last 12 months?</label> 
                <fieldset data-role="controlgroup" data-type="horizontal">
    
                <input data-mini="true" type="radio" name="rdIsSurgery" id="rdIsSurgeryYes" value="choice-1" />
                <label for="rdIsSurgeryYes">YES</label>
    
    
                <input data-mini="true"  type="radio" name="rdIsSurgery" id="rdIsSurgeryNo" value="choice-4"  />
                <label for="rdIsSurgeryNo">NO</label>
        </fieldset>  
    

    js code

     function  CheckRadioStateYN(val,rdButton){      
         try{
                 if (val==1){               
                     $('#' + rdButton + 'Yes').attr('checked', true).checkboxradio('refresh');
                     $('#' + rdButton + 'No').removeAttr('checked');          
                         }
             else{
             $('#' + rdButton + 'No').attr('checked', true).checkboxradio('refresh');
             $('#' + rdButton + 'Yes').removeAttr('checked');
    
             }        
            }
              catch(e)
              {alert(e);}
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class with like 20 fields which get populated from SQL database
I have a variable which I get from database I want to output this
I have sqlite3 database with locations which have a langitude and a longitude value.
I have a non-nullable database column which has a default value set. When inserting
I have a database which stores value in yyyy-MM-dd HH:mm:ss format. When I retrieve
I have a database which, simiplified, is as follows : ID | SecondID |
I have a database which is going to have UMT timestamps in standard sql
I have a database which contains the link to audio files. I am trying
I have a database which has a table recording when a vehicle was last
i have a database which contains an arabic tables , i can read it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.