Page 1 of 1

Echoing Selected Option List

Posted: Thu Aug 26, 2010 9:34 am
by marnieg
I have a form that the user fills in. I am also validating that certain fields have been inputted. If the user gets an error I want to echo the fields they already have filled out so they don't have to enter them again. I have this working on all types of input fields except for "Select Option". Here is my code.

Code: Select all

<td><select name='req_std_rec'>
         <option value=''>Select...</option>
         <option value = 'Y' <?php if ($req_std_rec == 'Y'): ?>select='selectetd'<?php endif; ?>>Yes</option>
         <option value = 'N' <?php if ($req_std_rec == 'N'): ?>select='selectetd'<?php endif; ?>>No</option>
      </select></td>
I think I'm close but have tried several versions of this code and still the echoing is not working. Also tried this without the "value =" part but not correct either.

Re: Echoing Selected Option List

Posted: Thu Aug 26, 2010 9:39 am
by marnieg
Fixed the spelling of "selected" but that was not the problem.

Re: Echoing Selected Option List

Posted: Thu Aug 26, 2010 9:44 am
by shawngoldw
I think it should be selected='selected', no? I just use SELECTED.

Shawn

Re: Echoing Selected Option List

Posted: Thu Aug 26, 2010 9:56 am
by marnieg
Thank you. I knew it was going to be something simple.

This forum is the best. I always find someone who can help and respond quickly and point me in the right direction. :D

Re: Echoing Selected Option List

Posted: Thu Aug 26, 2010 10:08 am
by shawngoldw
No problem