Forum Moderators: coopster
The problem I am having is when I go to pull the form up again with the already saved information in it to edit something else, this field will not mark either DVD, CD, or VHS with that is saved in the database already... Here is the code:
For the form
<input name="medium" type="radio" value="1" id="dvd"<?php echo dvd;?>>
<input name="medium" type="radio" value="2" id="cd"<?php echo cd;?>>
<input name="medium" type="radio" value="3" id="vhs"<?php echo vhs;?>>
For the backend and setting the variable to be checked
// if field is not empty
if (isset($_POST['medium'])) {
$selected_radiobtn = $_POST['medium'];
// set the value
if ($selected_radiobtn == '1') {
$dvd = 'checked';
}elseif($selected_radiobtn == '2') {
$cd = 'checked';
}elseif($selected_radiobtn == '3') {
$vhs = 'checked';
// if it is empy
} else {
// set the value to NULL
$medium = '';
}
Did a search on here and found this but Im not sure what I am doing wrong. [webmasterworld.com ]
Any help would be great! Been pulling my hair out all day on this one!
Modern Merlin
[edited by: Modern_Merlin at 6:31 am (utc) on Dec. 6, 2007]
but you'll also need a space in there or you'll end up with:
<input name="medium" type="radio" value="1" id="dvd"checked>
It's also a good idea to set the variables to blank beforehand so you don't generate any errors (which you may not see depending on the setting of your error level):
$dvd = '';
$cd = '';
$vhs = '';
if (isset($_POST['medium'])) {
.
.