最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

php - Hidden checkbox input values are not sent :( - Stack Overflow

programmeradmin2浏览0评论

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');
发布评论

评论列表(0)

  1. 暂无评论