I am working on a page where I show different input fields, depending on the selection that a user did.
Example 1:
<input type="text" name="color" value="" id="5">
<input type="text" name="location" value="" id="6">
<input type="text" name="age" value="" id="7">
Example 2:
<input type="text" name="color" value="" id="5">
<input type="text" name="destination" value="" id="8">
<input type="text" name="hours" value="" id="9">
<input type="text" name="date" value="" id="10">
Question 1: How can I get all input fields with jQuery when the input fields itself are dynamic?
Question 2: On the serverside, I want to process the input fields with their value and ID. How can I make this dynamic?
I know that this can be done easily when everything is fix, e.g.:
var color = $('#color').val();
var destination = $("#destination").val();
var dataString = 'color=' + color + "&destination=" + destination;
$.ajax({
type: "GET",
url: "do_something.php",
data: dataString,
async: false,
success: function(data){
console.log('success');
}
});