Home php CheckBox and PHP processing

CheckBox and PHP processing

Author

Date

Category

There is a checkbox, visually it is disabled (the check mark is removed), but HTML it is as follows:

& lt; input type = "checkbox" name = "type_edit []" value = "1" checked = "checked" & gt ;

Taco handler:

if ($ this- & gt; input- & gt; post ('type_edit')) {
  Foreach ($ this- & gt; Input- & gt; post ('type_edit') AS $ Val) {
    $ Data [] = $ VAL;
  }
  VAR_DUMP ($ DATA); DIE (); // nothing displays
} // does not enter this condition

Why so?


Answer 1, Authority 100%

visually it is disabled (check mark)

Well then, in fact, the question? Tick ​​to get $ _ post ['type_edit'] not empty (or rather to get it at all)

If Checkbox is not marked (check), then in the form it is not transmitted


Answer 2

Try the following code:

$ result = array ();
Foreach ($ _ post ['type_edit'] AS $ DATA)
 $ result [] = $ DATA;
Print_R ($ Result);

If something displays, then the problem with

$ this- & gt; input- & gt; post ('type_edit')

Answer 3

Why the attribute of Checked something to assign something. Try simply:
& lt; input type = "checkbox" name = "type_edit []" value = "1" Checked & gt;

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions