PDA

View Full Version : Re-populating radio button within a radio group.


Groshko
01-24-2010, 07:37 AM
Hi there,

I have this contact form that re-populates the fields when I deliberately fill out the form incorrectly and press submit. All the fields re-populate except for the radio group.

How can I make it so that the selected radio button is still selected after a incorrect form submission.


The site is
http://www.mozziewalk.org.au/singleentry.php


Source code is attached

Many Thanks

G

Jimmy Wu
01-25-2010, 11:24 AM
To accomplish this, you would need to write out your radio group dynamically using a loop. You would have to find the value that was selected and put in the code for it to be selected.

To add the selected code you would just add selected into the tag.

The unselected button looks like this:
<td width="70"> <p> <label>
<input name="TShirt" type="radio" id="XS" value="XS" />
XS</label></p></td>

The selected button would look like this:
<td width="70"> <p> <label>
<input name="TShirt" type="radio" id="XS" value="XS" selected/>
XS</label></p></td>