Hi there
I want my form to keep values entered by user after submit form. It works for input text fields but for lists and checkbox it refreshes the selection. I have no idea how lists can rember their selected option.
And this is what i'm doing for Checkbox
if (isset($_POST['cb1']))
{$_SESSION['cb1']= 'Yes';}
<input type="checkbox" name="cb1" value= "<?php echo $_SESSION['cb1']; ?>" onClick="validate();" >
Any help ??
Checkbox and list problem
Moderator: General Moderators
Re: Checkbox and list problem
Jack, for lists the value entered should be in the form:
<OPTION value="x" DEFAULT>$enteredValue</OPTION>
"default" is the key word
for check boxes:
<INPUT TYPE="CHECKBOX" NAME="sendmail" VALUE="send" CHECKED>
"checked" is the key word
<OPTION value="x" DEFAULT>$enteredValue</OPTION>
"default" is the key word
for check boxes:
<INPUT TYPE="CHECKBOX" NAME="sendmail" VALUE="send" CHECKED>
"checked" is the key word
-
limitdesigns
- Forum Commoner
- Posts: 25
- Joined: Sat Feb 06, 2010 9:05 pm
Re: Checkbox and list problem
To expand on that, you would have a php conditional to determine whether you add "checked='checked'" (this is the more valid option, rather than simply CHECKED) to the input tag. Something like...
Code: Select all
<input type="checkbox" <?php if(isset($_POST['cb1'])) { echo "checked='checked'";}?> name="cb1" />