[FX.php List] Displaying existing data in Form for radio/checkboxes (Resend)

Jonathan Schwartz jonathan at eschwartz.com
Sat Sep 24 13:08:52 MDT 2005


Mine was ugly because I had reversed the if logic, creating a 
separate set of the three inputs for each value choice.

In your method, there are essentially three single radio buttons, 
each with its own id statement.

Much neater.



BTW....What is the "/" for, before the end of input ">"?

>Hey Jonathan,
>You were on the right track with if statements, but they shouldn't get too
>ugly, especially if you're only dealing with single possibilities like radio
>Here's an example, which assumes that the field which can contain the Yes,
>No, or Maybe values is called 'eatDonuts'.
>Do you eat donuts?
><input name="eatDonuts" type="radio" id="eatDonuts" value="Yes" <?php
>if($dbData['data'][$dbKey]['eatDonuts'][0] == 'Yes') echo "checked";?>/> Yes
><input name="eatDonuts" type="radio" id="eatDonuts" value="No" <?php
>if($dbData['data'][$dbKey]['eatDonuts'][0] == 'No') echo "checked";?>/> No
><input name="eatDonuts" type="radio" id="eatDonuts" value="Maybe" <?php
>if($dbData['data'][$dbKey]['eatDonuts'][0] == 'Maybe') echo "checked";?>/>
>Hope this helps...


Jonathan Schwartz
Schwartz & Company
817 Marin Drive
Mill Valley, CA 94941
Phone: 415-381-1852
jonathan at eschwartz.com - http://www.eschwartz.com

More information about the FX.php_List mailing list