Jump to content
Larry Ullman's Book Forums

Sticky Radio Button Not Working


Recommended Posts

Here is the code that I have and on the first page that it appears, it allows the user to select only one of the options. However, when I return the full form for further editing by the user of all form items, this second of code always returns the checked option of 'owner'. The default option on the first page is 'none' and even if left at that, on the review page is is 'owner'. Any suggestions would be great.

 

==========First page code=======

<p><b>Joint Check to Who:</b>

<p> <input type="radio" name="jtchkname" value="none" checked="checked"/>None</p>

<p> <input type="radio" name="jtchkname" value="mycustomer"/>My Customer</p>

<p> <input type="radio" name="jtchkname" value="contractor" />Contractor</p>

<p> <input type="radio" name="jtchkname" value="lender"/>Lender</p>

<p> <input type="radio" name="jtchkname" value="owner"/>Owner</p>

<p> <input type="radio" name="jtchkname" value="other" />Other Name</p>

</p>

==========Review page code=======

 

<?PHP

$none_status = "unchecked";

$mycustomer_status = "unchecked";

$contractor_status = "unchecked";

$lender_status = "unchecked";

$owner_status = "unchecked";

// session jt_cknam is created from the post of jntchkname from first page

if ($_SESSION['jt_cknam'] == 'none') {

$none_status = "checked";

}

else if ($_SESSION['jt_cknam'] == 'mycustomer') {

$mycustomer_status = "checked";

}

else if ($_SESSION['jt_cknam'] == 'contractor') {

$contractor_status = "checked";

}

else if ($_SESSION['jt_cknam'] == 'lender') {

$lender_status = "checked";

}

else if ($_SESSION['jt_cknam'] == 'owner') {

$owner_status = "checked";

}

//}

 

?>

 

<p><b>Joint Check to Who:</b>

<p> <input type="radio" name="jtchkname" value="none" checked = '$none_status'/>None</p>

<p> <input type="radio" name="jtchkname" value="mycustomer" checked = '$mycustomer_status' />My Customer</p>

<p> <input type="radio" name="jtchkname" value="contractor" checked='$contractor_status'/>Contractor</p>

<p> <input type="radio" name="jtchkname" value="lender" checked = '$lender_status '/>Lender</p>

<p> <input type="radio" name="jtchkname" value="owner" checked = '$owner_status'/>Owner</p>

 

<P>

Mahalo

Link to comment
Share on other sites

Part of the problem could be the spaces around the equals signs. Part of the problem could be the use of single quotes instead of double quotes. It also could be the use of "unchecked". I've never personally seen or used checked="unchecked", although maybe that is valid.

Link to comment
Share on other sites

Larry, after rereading and then studying your Sticky form process in PHP6 and MYSQL 5 Visual Quickpro Guide, I made the following corrections to my code and the radio button process is now working correctly for me.

 

I first eliminated all the variable creation at the start and eliminated all the if else conditions that were working with the new variables that I created and just used what was already stored session variables from the original form.

 

<p><b>Joint Check You Selected to:</b>

 

 

<p> <input type="radio" name="jtchkname" <?PHP if ($_SESSION['jt_cknam']== 'none') {echo 'checked="checked"';} ?>/>None</p>

<p> <input type="radio" name="jtchkname" <?PHP if ($_SESSION['jt_cknam']== 'mycustomer') {echo 'checked="checked"';} ?>/>My Customer</p>

<p> <input type="radio" name="jtchkname" <?PHP if ($_SESSION['jt_cknam']== 'contractor') {echo 'checked="checked"';} ?>/>Contractor</p>

<p> <input type="radio" name="jtchkname" <?PHP if ($_SESSION['jt_cknam']== 'lender') {echo 'checked="checked"';} ?>/>Lender</p>

<p> <input type="radio" name="jtchkname" <?PHP if ($_SESSION['jt_cknam']== 'owner') {echo 'checked="checked"';} ?>/>Owner</p>

<p> <input type="radio" name="jtchkname" <?PHP if ($_SESSION['jt_cknam']== 'other') {echo 'checked="checked"';} ?>/>Other Name</p>

 

<P>

 

I just have to learn to read more intelligently and follow your great examples, but thought I would pass this on to maybe help others.

Mahalo

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

Loading...
 Share

×
×
  • Create New...