By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,949 Members | 1,824 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,949 IT Pros & Developers. It's quick & easy.

Radio Button - Reading Pre Selected Values from db

P: n/a
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
Jul 16 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Whilst lounging around on Wed, 06 Aug 2003 16:36:05 GMT, "entoone"
<en*****@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.
Jul 16 '05 #2

P: n/a
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]" <ia*@WINDOZEdigiserv.net> wrote in message
news:uc********************************@4ax.com...
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Whilst lounging around on Wed, 06 Aug 2003 16:36:05 GMT, "entoone"
<en*****@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.

Jul 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.