tmv105 Posted July 8, 2009 Share Posted July 8, 2009 I have checked the appropriate radio box from my database value, but now I need to be able to retrieve the edited choice to update my database. Here is the code: <?php $db_maritalstatus = $row_rsAdvancedPlan['maritalstatus']; ?> <input name="maritalstatus" id="maritalstatus" value="single"<?php if ($db_maritalstatus == "single") {echo 'checked=\"checked\"';} ?> type="radio" /> <label for="single" class="smaller">Single</label> <input name="maritalstatus" id="maritalstatus" value="married"<?php if ($db_maritalstatus == "married") {echo 'checked=\"checked\"';} ?> type="radio" /> <label for="married" class="smaller">Married</label> <input name="maritalstatus" id="maritalstatus" value="widowed"<?php if ($db_maritalstatus == "widowed") {echo 'checked=\"checked\"';} ?> type="radio" /> <label for="widowed" class="smaller">Widowed</label> <input name="maritalstatus" id="maritalstatus" value="divorced"<?php if ($db_maritalstatus == "divorced") {echo 'checked=\"checked\"';} ?> type="radio" /><label for="divorced" class="smaller">Divorced</label> When I select a new valuewhile editing form,my retrieval still holds the original value which loaded upon populating. Link to comment https://forums.phpfreaks.com/topic/165177-get-new-value-of-selected-radio-box/ Share on other sites More sharing options...
ignace Posted July 8, 2009 Share Posted July 8, 2009 Please post your all relevant code. The current code tells us nothing Link to comment https://forums.phpfreaks.com/topic/165177-get-new-value-of-selected-radio-box/#findComment-870965 Share on other sites More sharing options...
trq Posted July 8, 2009 Share Posted July 8, 2009 Your escaping double quotes unnecessarily, and have left out the space between the value and checked. <input name="maritalstatus" id="maritalstatus" value="single"<?php if ($db_maritalstatus == "single") {echo ' checked="checked"';} ?> type="radio" /> <label for="single" class="smaller">Single</label> ps; This could also be written as.... <input name="maritalstatus" id="maritalstatus" value="single"<?php echo ($db_maritalstatus == "single") ? ' checked="checked"' : '' ?> type="radio" /> <label for="single" class="smaller">Single</label> Link to comment https://forums.phpfreaks.com/topic/165177-get-new-value-of-selected-radio-box/#findComment-870984 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.