{"id":878,"date":"2014-11-11T14:30:48","date_gmt":"2014-11-11T14:30:48","guid":{"rendered":"http:\/\/www.nikola-breznjak.com\/blog\/?p=878"},"modified":"2015-08-17T06:10:46","modified_gmt":"2015-08-17T06:10:46","slug":"how-to-serialize-everything-but-the-checkbox-elements-in-jquery-serialize","status":"publish","type":"post","link":"https:\/\/nikola-breznjak.com\/blog\/stack-overflow\/how-to-serialize-everything-but-the-checkbox-elements-in-jquery-serialize\/","title":{"rendered":"How to serialize everything but the checkbox elements in jQuery.serialize()?"},"content":{"rendered":"<p><a href=\"http:\/\/stackoverflow.com\/users\/534755\/nikola\"><img loading=\"lazy\" decoding=\"async\" title=\"profile for Nikola at Stack Overflow, Q&amp;A for professional and enthusiast programmers\" src=\"http:\/\/stackoverflow.com\/users\/flair\/534755.png\" rel=\"lightbox[878]\" alt=\"profile for Nikola at Stack Overflow, Q&amp;A for professional and enthusiast programmers\" width=\"208\" height=\"58\" \/><\/a><br \/>\nI&#8217;m a big fan of <a href=\"http:\/\/stackoverflow.com\/\">Stack Overflow<\/a> and I tend to contribute regularly (am currently in the <a href=\"http:\/\/stackexchange.com\/leagues\/1\/alltime\/stackoverflow\/2008-07-31\/534755?sort=reputationchange#534755\">top 0.X%<\/a>).\u00a0In this category (<a href=\"http:\/\/www.nikola-breznjak.com\/blog\/category\/stack-overflow\/\">stackoverflow<\/a>)\u00a0of posts I will will be posting my top rated questions and answers. This, btw, is allowed as explained in the meta thread <a href=\"http:\/\/meta.stackoverflow.com\/questions\/266971\/can-i-post-so-questions-and-answers-in-a-personal-blog\/266973\">here<\/a>.<\/p>\n<p>My <a href=\"http:\/\/stackoverflow.com\/questions\/6607453\/how-to-serialize-everything-but-the-checkbox-elements-in-jquery-serialize\">quesiton<\/a> was if\u00a0there is a way to serialize all form elements using serialize() function except the checkboxes?<\/p>\n<p style=\"color: #000000;\"><span style=\"line-height: 1.5;\">The answer, by <a href=\"http:\/\/stackoverflow.com\/users\/419352\/simeon\">Simeon<\/a>,\u00a0was:<\/span><\/p>\n<blockquote><p>The .serialize() method can act on a jQuery object that has selected individual form elements, such as<code>&lt;input&gt;<\/code>,\u00a0<code>&lt;textarea&gt;<\/code>, and\u00a0<code>&lt;select&gt;<\/code>.<\/p>\n<p style=\"color: #000000;\">You could do this:<\/p>\n<pre class=\"default prettyprint prettyprinted\" style=\"color: #000000;\"><code><span class=\"kwd\" style=\"color: #00008b;\">var<\/span><span class=\"pln\"> s <\/span><span class=\"pun\">=<\/span><span class=\"pln\"> $<\/span><span class=\"pun\">(<\/span><span class=\"str\" style=\"color: #800000;\">'#post-form'<\/span><span class=\"pun\">).<\/span><span class=\"pln\">find<\/span><span class=\"pun\">(<\/span><span class=\"str\" style=\"color: #800000;\">'input, textarea, select'<\/span><span class=\"pun\">)<\/span><span class=\"pun\">.<\/span><span class=\"kwd\" style=\"color: #00008b;\">not<\/span><span class=\"pun\">(<\/span><span class=\"str\" style=\"color: #800000;\">':checkbox'<\/span><span class=\"pun\">)<\/span><span class=\"pun\">.<\/span><span class=\"pln\">serialize<\/span><span class=\"pun\">()<\/span><\/code><\/pre>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m a big fan of Stack Overflow and I tend to contribute regularly (am currently in the top 0.X%).\u00a0In this category (stackoverflow)\u00a0of posts I will will be posting&hellip;<\/p>\n","protected":false},"author":1,"featured_media":609,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[35],"tags":[],"class_list":["post-878","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-stack-overflow"],"_links":{"self":[{"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/posts\/878","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/comments?post=878"}],"version-history":[{"count":2,"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/posts\/878\/revisions"}],"predecessor-version":[{"id":1703,"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/posts\/878\/revisions\/1703"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/media\/609"}],"wp:attachment":[{"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/media?parent=878"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/categories?post=878"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nikola-breznjak.com\/blog\/wp-json\/wp\/v2\/tags?post=878"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}