I am making a website and i need to submit multiple values to a php file.
Because I could select inputs with $(‘input’) and call submit with ajax i did not make a form element.
I have a function in which i want to extract all input values and get a result as an array
I tried calling $('input').serialize(); and setting the result to $values but it did not return an array and some of my values were missing (like the ones from select tags)
What is the best way to get an array from all the input fields that do not belong to any form element??
To begin with, the reason your
selecttags were left out is because you need to use the following selector:Secondly use
.serializeArray()asThirdly, you need to provide a
nameattribute to your elements. See http://jsfiddle.net/pratik136/YV4Xe/EDIT:
A better way to select input fields in general would be using the
:inputselector as suggested by @elclanrs