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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:06:20+00:00 2026-06-18T05:06:20+00:00

I have a situation where there are 5 radio buttons, one default checked on

  • 0

I have a situation where there are 5 radio buttons, one default checked on page open. These radio buttons represent 5 categories. Within each category are several subcategory submit buttons. The subcategory buttons are hidden except for the ones in the category that is currently selected at radio button.

I want users to be able to select a category using the radio button then select from one of the subcategories, but on page refresh (from the $_POST request), i want the radio button of the ‘current’ category to remain checked. As it stands now the page refreshes with the submission of a subcategory submit and the radio is default checked to the first radio button category.

I have javascript coordinating the radio hide container action, so the form tags must seemingly cover all five radio buttons and all five radio buttons have the same name, which can’t be changed due to my underlying javascript. So i can’t simply change each radio’s name and code in PHP accordingly with sessions and such.

i actually got the category to stay on $_POST submission by using a session variable in the radio tag where you would find checked , but i had to encapsulate each radio and respective subcategory section within its own form tags. This causes problems with the javascript of course, and the radio buttons, once pushed, will not be able to be pushed again.

Is there a way to resolve this using php?

  • 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-18T05:06:21+00:00Added an answer on June 18, 2026 at 5:06 am

    I’ve had to do this with classes, its a little cumbersome. On page load, pull the checked item value into a variable ($val in this case). and have this inline for each input item:

    <input type="radio" ... value="someval" <?php $x = ($val=='someval' ? 'checked="checked"' : ''); echo $x; ?> />
    

    Like I said, cumbersome, but it checks the correct item. The only thing is that your first item will need to have some more if logic, since it will be defaulting to be checked if no value is chosen already.

    <input type="radio" ... value="firstval" <?php $x = ((empty($val)) || ($val=='firstval')) ? 'checked="checked"' : ''; echo $x; ?> /> //removed extra bracket
    

    You can prettify it as needed, that was just for inline.

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

Sidebar

Related Questions

I have this situation: There are a login page with a login form (form
I have the following situation: There is one custom view inside of the first
I have a really tough situation in here. There is an array of these
Let's say I have a situation in Silverlight where there is a background thread
I have the following situation. Assuming there are 3 systems: A,B,C and A is
I have a following situation in my project. There are some tag values which
There is a situation where I need to have a suspend kind of behavior
Strange situation. If I have these tables: CREATE TABLE t1 (id INT, title VARCHAR(20),
I have such situation: There is 8 div-blocks with ids like 'rateN_wrapper' where is
We have a situation where there are a dozen of files called config.properties in

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.