admin管理员组

文章数量:1356092

I have a set of check-boxes, which under certain conditions have their DIV container element hidden.

The problem is that values from these check-boxes are not sent through $_POST when they are not visible. How can I force them to be sent?

I have a set of check-boxes, which under certain conditions have their DIV container element hidden.

The problem is that values from these check-boxes are not sent through $_POST when they are not visible. How can I force them to be sent?

Share Improve this question edited Nov 18, 2011 at 20:08 Laurence Burke 2,35814 silver badges26 bronze badges asked Nov 18, 2011 at 20:01 AlexAlex 66.1k185 gold badges459 silver badges651 bronze badges 5
  • how are you imposing invisibility? are you removing them from the html? visiblility:hidden? or display:none? and what data are contained and why are they hidden? – Joseph Commented Nov 18, 2011 at 20:03
  • 4 Checkboxes are not sent unless they are checked – Laurence Burke Commented Nov 18, 2011 at 20:04
  • I'm not hiding them directly, I'm just hiding their container with $(el).hide(). This is what is confusing me... – Alex Commented Nov 18, 2011 at 20:06
  • Are you using AJAX to post the data to the server? – zzzzBov Commented Nov 18, 2011 at 20:10
  • 1 yes, I'm using serialize() to get the form fields data... – Alex Commented Nov 18, 2011 at 20:19
Add a ment  | 

2 Answers 2

Reset to default 9

It is not the visibility that is affecting if you can see the checkbox values. Checkbox values are not sent if the checkbox is not checked.

If the value does not exist in $_POST it has not been checked.

http://www.html-form-guide./php-form/php-form-checkbox.html

.hide() set the diplay to none;

visibility:hidden would work.

$(el).css('visibility', 'hidden');

本文标签: phpHidden checkbox input values are not sent (Stack Overflow