A few days ago I posted this question: http://stackoverflow.com/questions/1169387/switch-statement-and-loops-using-jquery-javascript
which ended up with me creating a series of divs using this code
for (var i = 1; i <= $("#play option:selected").text(); ++i) {
$("#play_"+i).slideDown().find("input").addClass("someClass");
}
My problem is that I now need to get the value of each #play
div and send that to a php script via ajax.
If I had a set number of divs I could do that easily, but how do I do it when I don't know how many #play there will be?
FURTHER DESCRIPTION!
It seems I didn't explain myself clearly in my original question so I will try and explain things better.
I want to make an AJAX call to a remote php script using the $.pos
t jQuery method. I can send information the remote script needs very easily. Here is an example:
$("#submit").click(function() {
$.post("../includes/process.php",
{
play_0: $("#play\_0").val(),
play_1: $("#play\_1").val(),
play_2: $("#play\_2").val(),
play_3: $("#play\_3").val(),
play_4: $("#play\_4").val()
},
function(data) {
$("#activityWindow").empty().append(data);
});
});
The php script can now access this information through the $_POST array - just like a normal form submission.
If I have generated divs (#play_) using a loop, I can't hard code the $.post
method in the way I have above. Really I need to include a loop in the syntax somewhere - I just can't work out how to do it! I hope this has made things clearer.