Bug Tracker

Ticket #9762 (closed bug: invalid)

Opened 3 years ago

Last modified 3 years ago

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

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

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.

Change History

comment:1 Changed 3 years ago by timmywil

  • Owner set to michael.bondi329@…
  • Priority changed from undecided to low
  • Status changed from new to pending
  • Component changed from unfiled to ajax

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.

comment:2 Changed 3 years ago by rwaldron

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

comment:3 Changed 3 years ago by michael.bondi329@…

  • Status changed from pending to new

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.

comment:4 Changed 3 years ago by rwaldron

  • Status changed from new to closed
  • Resolution set to invalid

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.

comment:5 Changed 3 years ago by anonymous

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.

comment:6 Changed 3 years ago by anonymous

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.

comment:7 Changed 3 years ago by anonymous

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.

comment:8 Changed 3 years ago by rwaldron

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

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

comment:9 Changed 3 years ago by anonymous

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

comment:10 Changed 3 years ago by anonymous

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

comment:11 Changed 3 years ago by anonymous

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?

Note: See TracTickets for help on using tickets.