Side navigation
#1069 closed enhancement (worksforme)
Opened March 25, 2007 08:33PM UTC
Closed October 04, 2010 01:49AM UTC
Please extend val()
Reported by: | daemach | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | 1.1.3 |
Component: | core | Version: | 1.1.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
At the moment, val() only works properly for single elements. It would be very useful if, when passing val() an array of elements created by using a selector like $('[@name=mycheckboxes]'), it could return an array of values for checkboxes and multi-selects. That is the only feature in the forms plugin I would use so I hate adding the overhead for just this function.
Attachments (0)
Change History (5)
Changed May 12, 2008 01:25AM UTC by comment:1
priority: | major → minor |
---|
Changed May 29, 2008 04:58AM UTC by comment:2
You can do that via the following:
$('[name="mycheckboxes"]').map(function(){ return this.checked; });
Changed January 31, 2009 05:23PM UTC by comment:3
Most likely, you are not looking for the value of the checkbox but the checked state? In that case you'd want either sunsean's solution or use something like
$("[name=mycheckboxes]:checked")and process them.
Changed April 12, 2009 10:01PM UTC by comment:4
yes, i agree with this suggestion. val() is confusing, given that it returns arrays for single elements and single elements for an array of elements.
$('one, two').val() should return the values of both elements, based on the way almost every other function behaves.
if not that, how about vals() (plural) in the core?
Changed October 04, 2010 01:49AM UTC by comment:5
resolution: | → worksforme |
---|---|
status: | new → closed |
Several good and short solutions have been proposed here as alternatives that work with the existing jQuery versions.
I think you can use the batch plugin by Brandon Aaron, it's very small (not like jQuery.form) and will solve this.