CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> Archive -> GotoCode Archive

 PHP - Setting a Radio Button?

Print topic Send  topic

Author Message
Nearly Normal Warren
Posted: 10/18/2003, 6:31 PM

I redisplay the contents of fields in a FORM where input type ="text", by using "value" in the HTML ...like this .. value="<?php print $field_value ?>"

However "value" is different for input type="radio", where multiple "value" entries spell out each of the several selections.

So, if a radio button can be an A, B or C and I want to set the radio button to whichever value I have for the user in my database, how do I set it and still let him change it on the FORM?
Nearly Normal Warren
Posted: 10/18/2003, 7:26 PM

I've got an answer but I don't like it.
It shouldn't take 20 lines of code to do this.

My solution is that at the point where I describe the radio button in HTML,
I drop into PHP and do IF/ELSE combinations for each value of the button. For each button value I issue the HTML with the "checked" specification in the proper place. It looks like this ....

<?php
if ($frm_status == "New") {
$mainhtml='
<td><input type="radio" name="rank" value="New" checked maxlength="8" size="8">New <input type="radio" name="rank" value="MIQ" maxlength="8" size="8">MIQ <input type="radio" name="rank" value="PTL" maxlength="8" size="8">PTL <input type="radio" name="rank" value="GL" maxlength="8" size="8">GL</td>
';
echo($mainhtml);
}
else if ($frm_status == "MIQ") {
$mainhtml='
<td><input type="radio" name="rank" value="New" maxlength="8" size="8">New <input type="radio" name="rank" value="MIQ" checked maxlength="8" size="8">MIQ <input type="radio" name="rank" value="PTL" maxlength="8" size="8">PTL <input type="radio" name="rank" value="GL" maxlength="8" size="8">GL</td>
';
echo($mainhtml);
}
else if .... AND SO ON.

   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.