Note that there are some explanatory texts on larger screens.

plurals
  1. PORemember form checkbox values
    text
    copied!<p>I want a form to remember the user's input whenever an error has occurred. I got this to work using for the text input using:</p> <pre><code>echo "&lt;input id=\"quote_square\" type=\"text\" name=\"square\" placeholder=\"Square\" value=\"". $_POST['square'] . "\"&gt;"; </code></pre> <p>For checkboxes I can't get this to work. I did find this example of how this can be done:</p> <pre><code> &lt;input type="checkbox" name="subscribe" &lt;?php echo (isset($_POST['opdracht'])?'checked="checked"':'') ?&gt; /&gt; </code></pre> <p>But I'm echoing my entire form into php and saving the checkbox input into an array:</p> <pre><code>echo "&lt;input id=\"quote_round\" type=\"text\" name=\"round\" placeholder=\"Round\" value=\"". $_POST['round'] . "\"&gt;"; echo "&lt;input id=\"quote_square\" type=\"text\" name=\"square\" placeholder=\"Square\" value=\"". $_POST['square'] . "\"&gt;"; echo "&lt;label class=\"checkbox\"&gt;&lt;input type=\"checkbox\" name=\"opdracht[]\" value=\"Blue\"&gt;Blue&lt;/label&gt;"; echo "&lt;label class=\"checkbox\"&gt;&lt;input type=\"checkbox\" name=\"opdracht[]\" value=\"Black\"&gt;Black&lt;/label&gt;"; echo "&lt;label class=\"checkbox\"&gt;&lt;input type=\"checkbox\" name=\"opdracht[]\" value=\"Red\"&gt;Red&lt;/label&gt;"; echo "&lt;label class=\"checkbox\"&gt;&lt;input type=\"checkbox\" name=\"opdracht[]\" value=\"White\"&gt;White&lt;/label&gt;"; </code></pre> <p>Can anybody give a suggestion how I can get the checkboxes to save the user's input?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload