views:

86

answers:

5

i want to get back an array of all:

  1. hidden inputs
  2. text inputs
  3. select inputs
  4. checkboxes

I see this page but it seems like you have to query for checkboxes seperately

is there anyway to have one selector get everything in one array?

+1  A: 

$('input, select') perhaps?

chelmertz
+1  A: 

$('input:hidden, input:text, input:checkbox, select')

Y. Shoham
+3  A: 

This will return what you're looking for I think...

$("input:hidden, input:text, select, input[type='checkbox']")

I'm not sure if you needed this or not as well but for text areas you'd also want to add...

$("textarea")
Ryan
+4  A: 

Depending on your goal, $('your_form_here').serialize() might be what you're looking for. It takes all values from a form, in order to for example submit it via AJAX.

See the docs on serialize()

chelmertz
Ryan's answer solved my problem but this is very useful
ooo
+2  A: 

Try these selectors:

  1. All hidden inputs: input[type=hidden]
  2. All text inputs: input[type=text], input:not([type])
  3. All selects: select
  4. All checkboxes: input[type=checkbox]
Gumbo
As Ryan stated below, you can use `input:text` etc. for shorter selectors, as mentiond here too http://docs.jquery.com/Selectors
Y. Shoham