Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear Friends,
I have this simple form

XML
<table  align="left" cellpadding="3" cellspacing="0" width="550" border="0">
          <form action="" name="WebToLeadForm" method="post" id="WebToLeadForm" onsubmit="javascript: return form_validation();">


XML
<tr>
                <td colspan="2" ><strong>What digital printing equipment do you have? </strong></td>
              </tr>
              <tr>
                <td >HP: </td>
                <td ><input id="printerhp_c" name="printerhp_c" type="checkbox" value="HP" value="<?php echo htmlentities($hp) ?>" />
                </td>
              </tr>
              <tr>
                <td >Xerox: </td>
                <td ><input id="printerxerox_c" name="printerxerox_c" type="checkbox" value="Xerox" value="<?php echo htmlentities($xerox) ?>" />
                </td>
              </tr>
              <tr>
                <td >Konica Minolta: </td>
                <td style="font-weight: normal;"><input id="printer_konicam_c" name="printer_konicam_c" type="checkbox" value="Konica Minolta" value="<?php echo htmlentities($km) ?>"/>
                </td>
              </tr>
              <tr>
                <td >Canon: </td>
                <td ><input id="printercanon_c" name="printercanon_c" type="checkbox" value="Canon"  value="<?php echo htmlentities($canon) ?>" />
                </td>
              </tr>
              <tr>
                <td >Kodak<span sugar="slot">: </span></td>
                <td ><input id="printerkodak_c" name="printerkodak_c" type="checkbox" value="Kodak"  value="<?php echo htmlentities($kodak) ?>"/>
                </td>
              </tr>
              <tr>
                <td >Ricoh: </td>
                <td ><input id="printerricoh_c" name="printerricoh_c" type="checkbox" value="Ricoh"  value="<?php echo htmlentities($ricoh) ?>" />
                </td>
              </tr>
              <tr>
                <td >Oc&eacute;: </td>
                <td ><input id="printeroce_c" name="printeroce_c" type="checkbox" value="Océ"   value="<?php echo htmlentities($oce) ?>"/>
                </td>
              </tr>
              <tr>
                <td >Other: </td>
                <td ><input id="printerother_c" name="printerother_c" type="checkbox" value="Other"  value="<?php echo htmlentities($other) ?>" />
                </td>
              </tr>


</form>


I just want that when i submit the form and code went wrong and page refresh/redirect all checkbox remain checked.

Thannks in
advance.
With Regards
Rajesh
Posted

if you use CHECKED KEY word to set a checkbox selected. example below:

PHP
if($value)//previously selected
{
 $checked="CHECKED";
}
else $checked="";
?>
<input type="CHECKBOX">>
</input>
 
Share this answer
 
Comments
[no name] 30-Jun-12 7:34am    
This i should put for every checkbox?
[no name] 30-Jun-12 7:36am    
did not get the exact solution or what u want to tell can you pls give a full example for atleast 2 checkboxes..

tanks
In php post
PHP
$check=$_POST['check'];



In html
HTML
<input id="check" name="check" type="checkbox" value="Other" <?php echo empty($_POST['check']) ? '' : ' checked="checked" '; ??> />
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900