Jump to content

Recommended Posts

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

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>

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.