You are mixing up server-side code and client-side code.
PHP is used on the server, and will produce the HTML that is sent to the browser (that HTML can include jquery). But the jquery will only work on the browser.
The problem is that you are using jquery commands on the server-side, with the following line...
(This is the 2nd if
statement in your eshop_extras_errorcheckout
function)
if($('#check_id').is(":checked"))
This should be PHP code, not jquery... something like...
if(isset($_POST('check_id'))){
// Do something
}
Additional based on OP's comment
The reason that your checkboxes are not remaining "checked" on the post-back of the page is because you are creating the <input type="checkbox"
code each time, and if you don't specifically provide the checked
attribute, it will be unchecked when the page is displayed.
(I'm not sure if you're familiar with ASP.NET, but in that technology if you tick a checkbox and then post-back, ASP.NET will handle this for you. PHP does not do it as standard, you need to tell it to check it.)
So, for instance, where you are "echo"ing the following line in your eshop_extras_checkout
function (note, this is contained with a PHP string, it is not straight mark-up):
<input type="checkbox" name="forms2[]" id="ArticlesOrderForm"
value="ArticlesOrderForm"> <b>Articles Order Form </b><br>
... you need to conditionally put the checked
attribute, something like this:
(isset($_POST('ArticlesOrderForm')) ? "Checked" : "")
... which would result in the string looking like
<input type="checkbox" name="forms2[]" id="ArticlesOrderForm"
value="ArticlesOrderForm" ' . (isset($_POST('ArticlesOrderForm')) ? "Checked" : "") . '> <b>Articles Order Form </b><br>
Therefore, when the final HTML is sent to the browser, the attribute checked
will appear if the checkbox was checked, and it won't if it won't.
Hope that makes sense