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 6742521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:51:11+00:00 2026-05-26T11:51:11+00:00

I have to create a radio button group dynamically.I am able to successfully create

  • 0

I have to create a radio button group dynamically.I am able to successfully create it.But the problem is that the dynamically created radio buttons do not look like the static ones.

I tried two approaches:
1) Called create on the fieldset – ui-corner-all class is getting added on an inner span and as a result all radio buttons appear rounded.
2) Called create on the div that encloses fieldset – Here the problem is better.But still some problems exist.At first,when there is only radio button, ui-controlgroup-last class is getting added to that radiobutton.Next,when the second radio button is added,the ui-controlgroup-last class is getting added to that radiobutton.But the ui-controlgroup-last is still present in the first radio button and this cycle repeats.As a result all radio buttons have the styles of last radiobutton.

This is my code:

<!DOCTYPE html>
<html lang="en">
<head>
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0rc1/jquery.mobile-1.0rc1.min.css" />
    <script src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
    <script src="http://code.jquery.com/mobile/1.0rc1/jquery.mobile-1.0rc1.min.js"></script>
    <script>
$(document).ready(function()
{
    for (var i = 0; i < 3; i++)
    {
        $("#rgroup1").append('<input type="radio" name="rg1" id="radio1-'+i+'"/><label for="radio1-'+i+'">Value</label>');
        $("#rgroup1").trigger("create");

        $("#rgroup2").append('<input type="radio" name="rg2" id="radio2-'+i+'"/><label for="radio2-'+i+'">Value</label>');
        $("#radiodiv1").trigger("create");

    }
});

    </script>
</head>

<body>
  <div data-role="content">
    <h3>Normal radio buttons</h3>
    <div id="radiodiv">
        <fieldset data-role="controlgroup" id="rgroup">
            <input type="radio" name="rg" id="radio-1"/><label for="radio-1">Value</label>
            <input type="radio" name="rg" id="radio-2"/><label for="radio-2">Value</label>
            <input type="radio" name="rg" id="radio-3"/><label for="radio-3">Value</label>
        </fieldset>
    </div>
    <h3>Dynamically created-Div Refresh</h3>
    <div id="radiodiv">
        <fieldset data-role="controlgroup" id="rgroup1">
        </fieldset>
    </div>
     <h3>Dynamically created-Fieldset Refresh</h3>
    <div id="radiodiv1">
        <fieldset data-role="controlgroup" id="rgroup2">
        </fieldset>
    </div>
  </div>
</body>

P.S – The reason why I am calling create after each append is because thats how it works in my actual usecase-Only one radio button is created at any time.

The generated source

<html lang="en" class="ui-mobile"><head><base href="http://localhost:8081/html5/calendar-new/radio_issue.html">
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0rc1/jquery.mobile-1.0rc1.min.css">
    <script src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
    <script src="http://code.jquery.com/mobile/1.0rc1/jquery.mobile-1.0rc1.min.js"></script>
    <script>
$(document).ready(function()
{
    for (var i = 0; i < 3; i++)
    {
        $("#rgroup1").append('<input type="radio" name="rg1" id="radio1-'+i+'"/><label for="radio1-'+i+'">Value</label>');
        $("#rgroup1").trigger("create");

        $("#rgroup2").append('<input type="radio" name="rg2" id="radio2-'+i+'"/><label for="radio2-'+i+'">Value</label>');
        $("#radiodiv1").trigger("create");

    }
});

    </script>
<title></title></head>

<body class="ui-mobile-viewport"><div data-role="page" data-url="/html5/calendar-new/radio_issue.html" tabindex="0" class="ui-page ui-body-c ui-page-active" style="min-height: 933px; ">
  <div data-role="content" class="ui-content" role="main">
    <h3>Normal radio buttons</h3>
    <div id="radiodiv">
        <fieldset data-role="controlgroup" id="rgroup" class="ui-corner-all ui-controlgroup ui-controlgroup-vertical">
            <div class="ui-radio"><input type="radio" name="rg" id="radio-1"><label for="radio-1" data-theme="c" class="ui-btn ui-btn-icon-left ui-radio-off ui-corner-top ui-btn-up-c"><span class="ui-btn-inner ui-corner-top"><span class="ui-btn-text">Value</span><span class="ui-icon ui-icon-radio-off ui-icon-shadow"></span></span></label></div>
            <div class="ui-radio"><input type="radio" name="rg" id="radio-2"><label for="radio-2" data-theme="c" class="ui-btn ui-btn-icon-left ui-radio-off ui-btn-up-c"><span class="ui-btn-inner"><span class="ui-btn-text">Value</span><span class="ui-icon ui-icon-radio-off ui-icon-shadow"></span></span></label></div>
            <div class="ui-radio"><input type="radio" name="rg" id="radio-3"><label for="radio-3" data-theme="c" class="ui-btn ui-btn-icon-left ui-radio-off ui-corner-bottom ui-controlgroup-last ui-btn-up-c"><span class="ui-btn-inner ui-corner-bottom ui-controlgroup-last"><span class="ui-btn-text">Value</span><span class="ui-icon ui-icon-radio-off ui-icon-shadow"></span></span></label></div>
        </fieldset>
    </div>
    <h3>Dynamically created-Div Refresh</h3>
    <div id="radiodiv">
        <fieldset data-role="controlgroup" id="rgroup1" class="ui-corner-all ui-controlgroup ui-controlgroup-vertical">
        <div class="ui-radio"><input type="radio" name="rg1" id="radio1-0"><label for="radio1-0" data-theme="c" class="ui-btn ui-btn-icon-left ui-btn-corner-all ui-radio-off ui-btn-up-c"><span class="ui-btn-inner ui-btn-corner-all"><span class="ui-btn-text">Value</span><span class="ui-icon ui-icon-radio-off ui-icon-shadow"></span></span></label></div><div class="ui-radio"><input type="radio" name="rg1" id="radio1-1"><label for="radio1-1" data-theme="c" class="ui-btn ui-btn-icon-left ui-btn-corner-all ui-radio-off ui-btn-up-c"><span class="ui-btn-inner ui-btn-corner-all"><span class="ui-btn-text">Value</span><span class="ui-icon ui-icon-radio-off ui-icon-shadow"></span></span></label></div><div class="ui-radio"><input type="radio" name="rg1" id="radio1-2"><label for="radio1-2" data-theme="c" class="ui-btn ui-btn-icon-left ui-btn-corner-all ui-radio-off ui-btn-up-c"><span class="ui-btn-inner ui-btn-corner-all"><span class="ui-btn-text">Value</span><span class="ui-icon ui-icon-radio-off ui-icon-shadow"></span></span></label></div></fieldset>
    </div>
     <h3>Dynamically created-Fieldset Refresh</h3>
    <div id="radiodiv1">
        <fieldset data-role="controlgroup" id="rgroup2" class="ui-corner-all ui-controlgroup ui-controlgroup-vertical">
        <div class="ui-radio"><input type="radio" name="rg2" id="radio2-0"><label for="radio2-0" data-theme="c" class="ui-btn ui-btn-icon-left ui-radio-off ui-corner-top ui-corner-bottom ui-controlgroup-last ui-btn-up-c"><span class="ui-btn-inner ui-corner-top ui-corner-bottom ui-controlgroup-last"><span class="ui-btn-text">Value</span><span class="ui-icon ui-icon-radio-off ui-icon-shadow"></span></span></label></div><div class="ui-radio"><input type="radio" name="rg2" id="radio2-1"><label for="radio2-1" data-theme="c" class="ui-btn ui-btn-icon-left ui-radio-off ui-corner-bottom ui-controlgroup-last ui-btn-up-c"><span class="ui-btn-inner ui-corner-bottom ui-controlgroup-last"><span class="ui-btn-text">Value</span><span class="ui-icon ui-icon-radio-off ui-icon-shadow"></span></span></label></div><div class="ui-radio"><input type="radio" name="rg2" id="radio2-2"><label for="radio2-2" data-theme="c" class="ui-btn ui-btn-icon-left ui-radio-off ui-corner-bottom ui-controlgroup-last ui-btn-up-c"><span class="ui-btn-inner ui-corner-bottom ui-controlgroup-last"><span class="ui-btn-text">Value</span><span class="ui-icon ui-icon-radio-off ui-icon-shadow"></span></span></label></div></fieldset>
    </div>
  </div>

</div><div class="ui-loader ui-body-a ui-corner-all" style="top: 290px; "><span class="ui-icon ui-icon-loading spin"></span><h1>loading</h1></div></body></html>
  • 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-05-26T11:51:12+00:00Added an answer on May 26, 2026 at 11:51 am

    I fixed this issue by explicitly removing the ui-controlgroup-last and ui-corner-bottom classes from all the labels except the label for the last radio button

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0rc1/jquery.mobile-1.0rc1.min.css" />
        <script src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
        <script src="http://code.jquery.com/mobile/1.0rc1/jquery.mobile-1.0rc1.min.js"></script>
        <script>
    $(document).ready(function()
    {
        for (var i = 0; i < 3; i++)
        {
            /*$("#rgroup1").append('<input type="radio" name="rg1" id="radio1-'+i+'"/><label id="label1-'+i+'" for="radio1-'+i+'">Value</label>');
            $("#rgroup1").trigger("create");*/
    
    
            $("#rgroup2").append('<input type="radio" name="rg2" id="radio2-'+i+'"/><label id="label2-'+i+'"for="radio2-'+i+'">Value</label>');
            $("#radiodiv1").trigger("create");
    
    
        }
        for (var i = 0; i < 2; i++)
        {
            $('#label2-'+i).removeClass("ui-controlgroup-last ui-corner-bottom");
        }
    });
    
        </script>
    </head>
    
    <body>
      <div data-role="content">
        <h3>Normal radio buttons</h3>
        <div id="radiodiv">
            <fieldset data-role="controlgroup" id="rgroup">
                <input type="radio" name="rg" id="radio-1"/><label for="radio-1">Value</label>
                <input type="radio" name="rg" id="radio-2"/><label for="radio-2">Value</label>
                <input type="radio" name="rg" id="radio-3"/><label for="radio-3">Value</label>
            </fieldset>
        </div>
        <!-- <h3>Dynamically created-Div Refresh</h3>
        <div id="radiodiv">
            <fieldset data-role="controlgroup" id="rgroup1">
            </fieldset>
        </div> -->
         <h3>Dynamically created-Fieldset Refresh</h3>
        <div id="radiodiv1">
            <fieldset data-role="controlgroup" id="rgroup2">
            </fieldset>
        </div>
      </div>
    </body>
    

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have Radio buttons that are created dynamically. LinearLayout linLayRoot = (LinearLayout)dialogView.findViewById(R.id.dialog_layout_root); RadioGroup radGp
i have a table which contains a bunch of dynamically created radio button lists,
I am trying to dynamically create a list of radio buttons that represents the
I use an object to check that a group of radio buttons have a
On form submission, it's telling me that it was successfully created but it's not
I have a problem with my radio buttons. What I'm doing is I create
Situation:- I have created a RadioButton group. When a User selects a radio button
I have created radio button like this: @foreach (LoanQuestionIncludesStatement statement in item.Statements) { _question
I need to create dynamic radio button in my table.I have a table in
I have a button that will create a new entry (row in a table)

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.