Radio Button - Reading Pre Selected Values from db

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 ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 08-06-2003
entoone
 
Posts: n/a
Default Radio Button - Reading Pre Selected Values from db

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


Reply With Quote
  #2 (permalink)  
Old 08-06-2003
entoone
 
Posts: n/a
Default Re: Radio Button - Reading Pre Selected Values from db

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.



Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 10:02 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0