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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T22:54:20+00:00 2026-05-20T22:54:20+00:00

So I have a Radio button group, like so: <div data-role=fieldcontain> <fieldset data-role=controlgroup> <legend>Choose

  • 0

So I have a Radio button group, like so:

<div data-role="fieldcontain">
    <fieldset data-role="controlgroup">
        <legend>Choose a pet:</legend>
            <input type="radio" name="radio-choice-1" id="radio-choice-1" value="choice-1" checked="checked" />
            <label for="radio-choice-1">Cat</label>

            <input type="radio" name="radio-choice-1" id="radio-choice-2" value="choice-2"  />
            <label for="radio-choice-2">Dog</label>

            <input type="radio" name="radio-choice-1" id="radio-choice-3" value="choice-3"  />
            <label for="radio-choice-3">Hamster</label>

            <input type="radio" name="radio-choice-1" id="radio-choice-4" value="choice-4"  />
            <label for="radio-choice-4">Lizard</label>
    </fieldset>
</div>

Now if I just submit the for I get this $_POST (Note I have multiple Radio group questions)

Array
(
    [radio-choice-1] => choice-1
    [radio-choice-2] => choice-4
    [radio-choice-3] => choice-2
    [submit] => submit
    [PHPSESSID] => 11111111111111111
)

How Can I restructure the HTML or $_POST data before submission to make it look like this:

Array
(
    [type-1] => radio-choice-1
    [answer-1] => choice-1
    [type-2] => radio-choice-2
    [answer-2] => choice-4
    [type-3] => radio-choice-3
    [answer-3] => choice-2
    [submit] => submit
    [PHPSESSID] => 11111111111111111
)

Maybe jQuery as an option?

  • 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-20T22:54:21+00:00Added an answer on May 20, 2026 at 10:54 pm

    You can do it post submission, the code below should work if you keep your original naming conventions.

    $postValues = $_POST;
    $altered = Array();
    $unaltered = Array();
    
    foreach ($postValues as $key => $val) {
    
      if ( FALSE !== stripos($key, 'radio-choice-') ) {
    
        $num = explode('-', $key);
        $num = $num[2];
        $altered['type-'.$num] = $key;
        $altered['answer-'.$num] = $value;
    
      } else {
    
        $unAltered[$key] = $value;
    
      }  
    
    }
    
    $manipulatedPOSTData = array_merge($altered, $unAltered);
    
    // Keep doing what you intended
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have one group of radiobutton: <div id=id1> <input id=pack1 type=radio class=pack name=pack value=OK
I have a radio button group like this : <g:radioGroup name=myGroup values=[1,2,3] value=1 >
I have 3 different radio button group in jQuery like so: <tr class=toValidate> <td>Please
I have a radio button group on a survey form whose html looks like:
I have created radio button like this: @foreach (LoanQuestionIncludesStatement statement in item.Statements) { _question
We have a form with a radio button group, where any one of the
I have a radio group with two radiobuttons. each button has a custom selector.
I have a table whose rows contain radio button groups like so: <td class=usegsm>
I have a few radio buttons in a group, one of them being: <input
I have some radio buttons and I'd like to have different hidden divs show

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.