Skip to main content

Bug Tracker

Side navigation

#9762 closed bug (invalid)

Opened July 06, 2011 08:41PM UTC

Closed July 07, 2011 11:25PM UTC

Last modified September 02, 2011 05:41PM UTC

.serialize() not serializing checkboxes within a form formatted with a table

Reported by: michael.bondi329@gmail.com Owned by: michael.bondi329@gmail.com
Priority: low Milestone: 1.next
Component: ajax Version: 1.4.4
Keywords: Cc:
Blocked by: Blocking:
Description

This concerns .serialize() method used on a form that is formatted with a table.

When it serializes the checkbox, the name shows with a null value, no matter if it is checked or not. All other inputs (text) serialize fine.

I can get around the problem, but I see nothing discussing this issue, so I thought I'd let you guys know.

Attachments (0)
Change History (11)

Changed July 06, 2011 08:58PM UTC by timmywil comment:1

component: unfiledajax
owner: → michael.bondi329@gmail.com
priority: undecidedlow
status: newpending

Thanks for taking the time to contribute to the jQuery project! Please provide a reduced test case on http://jsfiddle.net that reproduces the issue experienced to help us assess your ticket.

Additionally, test against the jQuery (edge) version to ensure the issue still exists.

Changed July 07, 2011 01:56PM UTC by rwaldron comment:2

Please be sure that your checkbox markup includes the name attribute (matching the ID) name="something" is required for use with serialize()

Changed July 07, 2011 03:05PM UTC by michael.bondi329@gmail.com comment:3

status: pendingnew

The name tag is in there. If I remove the table markup, the checkboxes serialize fine. I also wanted to add that this form is within a JQuery UI tab, with a "$('body').delegate('form','submit', function() { " event attached to the form.

Changed July 07, 2011 11:25PM UTC by rwaldron comment:4

resolution: → invalid
status: newclosed

No matter what, the table, jQuery UI and delegate have nothing to do with anything, ever, at all. Proof: http://jsfiddle.net/rwaldron/YZxYA/

Checkboxes won't appear in your serialization unless they have something to offer.

Changed September 01, 2011 04:18AM UTC by anonymous comment:5

Hello, I am not able to get serialize() to give the values for checkboxes period. They either show checkboxName="" or nothing at all. My checkboxes have their names and ids the same and have an associated value. The value is not being output in serialize. Please help, thanks.

Changed September 01, 2011 04:26AM UTC by anonymous comment:6

Ok, so I found what causes the issue. If I have a dash (-) in my name or id, it doesn't work. However, if there dash is removed everything works fine.

Changed September 01, 2011 04:38AM UTC by anonymous comment:7

Ok, so apparently if I use the name "hide-fullname-input" everything works. I have pasted my code below. If I use "hide-full-full-input" it doesn't work. I am suspecting some sort of a name clash with hide-full-name-item. Check out the code:

?><div id='hide-full-name-item' class='profile-item'>

<div class='profile-input'>

<input id='hide-full-name-input' name='hide-full-name-input' type="checkbox" value="hide" >

<span id='checkbox-text'>Hide Full Name</span>

<p>Hide your first and last name on your bio.</p>

</div>

</div>

<div class="clear"></div><?php

Interestingly, I just changed the name from hide-full-name-input to hide-full-name-checkbox, and it worked. Hell if I know what the bug is, but I am going to use the new names.

Changed September 01, 2011 04:53PM UTC by rwaldron comment:8

For a checked item to be serialized, it actually has to be checked....

http://jsfiddle.net/rwaldron/txZjM/

Changed September 01, 2011 11:51PM UTC by anonymous comment:9

It was checked, it was just outputting a NULL value. There is some sort of name clash bug going on.

Changed September 02, 2011 01:36AM UTC by anonymous comment:10

Do you have 'value="x"' where x could be true, on, etc in the input tag?

Changed September 02, 2011 05:41PM UTC by anonymous comment:11

Dashes in field name and ID do not make a difference for me. Checkboxes in table format will not serialize at all. Any other ideas?