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

  • Home
  • SEARCH
  • 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 9159049
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:23:54+00:00 2026-06-17T13:23:54+00:00

html: <label><input type=radio name=league value=Bronze>Bronze</label> <label><input type=radio name=league value=Silver>Silver</label> <label><input type=radio name=league value=Gold>Gold</label> <label><input

  • 0

html:

<label><input type="radio" name="league" value="Bronze">Bronze</label>
<label><input type="radio" name="league" value="Silver">Silver</label>
<label><input type="radio" name="league" value="Gold">Gold</label>
<label><input type="radio" name="league" value="Platinum">Platinum</label>
<label><input type="radio" name="league" value="Diamond">Diamond</label>
<label><input type="radio" name="league" value="Master">Master</label>
<label><input type="radio" name="league" value="Grand Master">Grand Master</label>

I have a database column that will save the one they select as a VARCHAR (should I be using something else?). How do I set it up so that the radio button that lines up with what is stored in the database will be selected?

I may also just change this to a drop down menu, but I will still need to know how to set the selected value for that as well.

Here is what I have tried, but it doesn’t seem to work for some reason.

<?php
     $leagues = array('Bronze', 'Silver', 'Gold', 'Platinum', 'Diamond', 'Master', 'Grand Master');
     foreach ($leagues as $key=>$value) {
          $selected = ($value == $user_data['league'] ? ' selected="selected"' :  '');
          echo '<label><input type="radio" name="league"' . $selected . ' value="' . $value . '">' . $value . '</label> ';
     }
?>
  • 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-17T13:23:55+00:00Added an answer on June 17, 2026 at 1:23 pm

    First, get the stored value from your db. What server-side language are you using?

    Edit: added php.

    <?php
     $leagues = array('Bronze', 'Silver', 'Gold', 'Platinum', 'Diamond', 'Master', 'Grand Master');
     foreach ($leagues as $key=>$value) {
          $selected = ($value == $user_data['league'] ? ' checked="checked"' :  '');
          echo '<label><input type="radio" name="league"' . $selected . ' value="' . $value . '">' . $value . '</label> ';
     }
    ?>
    
    <script>
    var value = <? /* Your PHP code to get the stored value from the db...*/ ?>;
    
    /* radioOptions will store the array of radio buttons.*/
    var radioOptions = document.getElementsByName("league");
    var i;
    for (i = 0; i < radioOptions.length; i++) {
        /* Check if the value of the radio option matches the stored value.*/
        if (radioOptions[i] === value) {
            radioOptions[i].checked = true;
            /* No need to check the others.*/
            break;
        }
    }    
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some HTML like this: <input type=radio class=MyRadio name=TheName> <label for=TheLabel>the text</label> How
I have the following bit of HTML: <label>First Name</label><input name=Question62 type=text value= /> Unfortunately
The default decorator for the Zend_Form_Element_Radio is <label for=type_id-1><input type=radio name=type_id id=type_id-1 value=1>Pack</label> The
I've following html structures : <div id=options> <input type=radio id=option0 value=option0 checked='checked' /><label>All</label> <input
HTML <form id=contact_form action=# name= method=POST> <label for=name>NAME</label> <input type=text name=name id=name class=contact_form_input />
form html: <form action='/register/' method = 'post'>{% csrf_token %} ... <label>Avatar: </label><input type='file' name='avatar'
Here's my HTML code: <label><input type=radio id=fNuttig /> Nuttig</label> <label><input type=radio id=fNietNuttig /> Niet
Can somebody help me with this. There is HTML code: <h3> <label> <input type=checkbox
Hi I have a form that data post something weird... HTML: <form> <input type=radio
I have a jQuery script that finds all the input type=radio in the html

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.