This is a discussion on Radio Button - Reading Pre Selected Values from db within the PHP Language forums, part of the PHP Programming Forums category; I am able to make a selection of information when entering a record, with radio buttons giving the option of ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
I am able to make a selection of information when entering a record, with
radio buttons giving the option of yes, or no. Which stores their answer as yes, or no in the database. I then have an update record page that reads information in the database, and presently it will not retrieve the previously selected option from the database. I have tried all sorts of if else statements, and can't get anything to work. I want the previously selected option to be selected when they are entering the update page. Thus, they have the option to change it, but want their previous setting selected so they are aware of their currently selected option is. <td width="50%"> <input type="radio" name="ud_digdocs" value="Yes">Yes <input type="radio" name="ud_digdocs" value="No" checked>No |
|
|||
|
Thanks for the reply...
I found another example on the web while trying to still working on solving this and Mark Baker had a post on another site that had a great example. So the fix for me was. <? $check0 = $check1 = ""; if ($digdocs == "Yes") { $check0 = " CHECKED"; } else { $check1 = " CHECKED"; } echo '<INPUT TYPE="RADIO" NAME="ud_digdocs" VALUE="Yes"'.$check0.'>Yes<BR>'; echo '<INPUT TYPE="RADIO" NAME="ud_digdocs" VALUE="No"'.$check1.'>No'; ?> This allows the update page to read the values of the radio button, that is presnetly stored in the database. Thanks again! "Ian.H [dS]" <ian@WINDOZEdigiserv.net> wrote in message news:ucn2jvo468e7v6si3h3jrqkl9kdrq2qdmp@4ax.com... > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Whilst lounging around on Wed, 06 Aug 2003 16:36:05 GMT, "entoone" > <entoone@pacbell.net> amazingly managed to produce the following with > their Etch-A-Sketch: > > > I am able to make a selection of information when entering a > > record, with radio buttons giving the option of yes, or no. > > > > Which stores their answer as yes, or no in the database. I then > > have an update record page that reads information in the database, > > and presently it will not retrieve the previously selected option > > from the database. I have tried all sorts of if else statements, > > and can't get anything to work. I want the previously selected > > option to be selected when they are entering the update page. Thus, > > they have the option to change it, but want their previous setting > > selected so they are aware of their currently selected option is. > > > > <td width="50%"> <input type="radio" name="ud_digdocs" > > value="Yes">Yes > > <input type="radio" name="ud_digdocs" value="No" checked>No > > > > > $checked = ($db_stuff->option == 'Yes') ? 'checked="checked" ' ''; > echo > '<input type="radio" name="ud_digdocs" value="No" ' . $checked . > '/>'; > > > HTH. > > > > Regards, > > Ian > > -----BEGIN PGP SIGNATURE----- > Version: PGP 8.0 > > iQA/AwUBPzFeTmfqtj251CDhEQIaQQCfQAdKBxvZvkMSfQ5al2Zr39 d6aFYAnjmA > DK3R7CB737+/+vJ8FLcHzM5A > =6DFI > -----END PGP SIGNATURE----- > > -- > Ian.H [Design & Development] > digiServ Network - Web solutions > www.digiserv.net | irc.digiserv.net | forum.digiserv.net > Programming, Web design, development & hosting. |