Click here to Skip to main content
15,885,365 members

how to Retaining selected value of checkboxes in postback form in php

Rajeshkrathor asked:

Open original thread
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
Tags: PHP

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



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