Hi folks, getting a problem adding name/values to make an array to pass to php.
I've got a number of inputs named week_start_x (where x is an integer ranging from 1 to a dynamic number [generated through php] - the max no. is determined by another field called 'yearblocks').
I want to pass these name/value pairs to a php script. However, I get an 'undefined' when I fish out the $_POST variables for the array. Anybody help me out? I assume it's to do with the fact that the 'str' variable is printing out a string as opposed to a list of name/values, but I have no idea of how to go about this.
var cnt = 1;
str = "";
blocks = $("#yearblocks").val();
while (cnt <= blocks){
str = str + ',{name: "week_start[\'' + cnt + '\']", value: "' + $('#week_start_' + cnt).val() + '"}';
cnt++;
}
var data = [
{ name: "step", value: "2"} , str
];
$.post("includes/receive.php", data , function(msg){ ...(etc)...
});