Jump to content

Radio Button With With Only Initial Default Value


gsingh2011
 Share

Recommended Posts

I have a site with a few radio buttons and a submit button. By default, the first button is selected. Whenever I press submit, the first button is selected again. However, I want whatever the last selected button was to stay selected. The form is submitted to a php script in the same file. How do I set an initial default value but have the last radio button selected remain checked?

Link to comment
Share on other sites

Since it is in the same document, and PHP is capturing the value of the selected button, PHP can also set the checked value of the correct button. Something like:<input type="radio" name="something" value="1" <?php if ($x) echo 'checked="checked"' ?> >

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...