radio button staying selected after submit

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
altec-webdeveloper
Forum Newbie
Posts: 1
Joined: Wed Dec 14, 2011 5:37 pm

radio button staying selected after submit

Post by altec-webdeveloper »

I've been racking my brain and have tried every suggestion Google has thrown at me in regards to keeping the selected radio buttons to stay selected once the form has been submitted. This is a $session based form, in which each logged in user will have the ability to fill out. I've been able to keep the data from the input and text fields to remain populated, but not the radio buttons; or the check-boxes for that matter. The selection of the radio button does save in the database column named 'quotationinsurance' but for the life of me, I cant keep the button selected! :-(

Below is a snip-it of the database column that is storing the selected information:

Column: quotationinsurance
Type: VARCHAR
Lenght/Values: 20
Default: None

Below is a snip-it of the radio buttons from my php form - formOneEdit.php

Code: Select all

<td width="24"><span class="med"> 
                            <input type="radio" name="quotationinsurance" value="<?php
			if($form->value("quotation") == ""){
				echo $session->userinfo['quotation'];
				echo 'quotation';
			}else{
				echo $form->value("quotation");
			}
			?>" class="btn" onMouseOver="hov(this,'btn btnhov')" onMouseOut="hov(this,'btn')" />
                            </span></td>
                          <td width="54"><span class="small">Insurance</span></td>
                          <td width="271"><span class="med">
                            <input type="radio" name="quotationinsurance" value="<?php
			if($form->value("insurance") == ""){
				echo $session->userinfo['insurance'];
				echo 'insurance';
			}else{
				echo $form->value("insurance");
			}
			?>" class="btn" onMouseOver="hov(this,'btn btnhov')" onMouseOut="hov(this,'btn')" />
                            </span></td>
Let me know if you have any, well; preferably new suggestions, because I have tried every suggestion from all the forums. From PHP echo Checked = checked to javascript onClick functions. None seem to work. This form also uses a process.php and a session.php file

If you need check out the form, I can set up a guest username and password so you can check it out if need be....

Any help would be appreciated
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: radio button staying selected after submit

Post by social_experiment »

“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Post Reply