I hope I am able to explain what I'm trying to do properly, but I am trying to use AJAX to pass (using POST) quite a number of Dates to PHP file, to do checks if dates are valid (e.g. 31-FEB, 31-Apr). I am not sure how many dates there will be, there are 12 entry boxes, maximum case 12 dates, minimum case 1. So the number of dates passed to the PHP file could be anything. I want to be able to "roll" through (using numbers 0 1 2 like in an array) all the dates (and their D, M, Y) inside the PHP file, and also "roll" through dates passed back to the JS from PHP.
Jquery
var DAT = {}; //is such a declaration valid for an array?
k=0;
for(x=1;x<=12;x++)
{ I = "#ED" + x;
d= $(I).children('.dd').val();
m= $(I).children('.mmm').val();
y= $(I).children('.yyyy').val();
c= date_chk(d,m,y); //returns '1' if date ok
if(c==1) //Date OK
{ DATE[k] = [d,m,y];
alert(DATE[k][0]+" "+DATE[k][1]+" "+DATE[k][2]);
k++;
}
}
AJ.onreadystatechange = function(){
if((AJ.readyState == 4) && (AJ.status == 200))
{ var PH_RP = AJ.responseText;
alert("PHP REPLY:: " + PH_RP);
var DATE_Lst = JSON.parse(PH_RP);
alert("DATE1 Day::" + DATE_Lst.DT[0][0] + "DATE1 Month::" + DATE_Lst.DT[0][1] +"DATE1 Year::" + DATE_Lst.DT[0][2] );
alert("DATE2 Day::" + DATE_Lst.DT[1][0] + "DATE2 Month::" + DATE_Lst.DT[1][1] +"DATE2 Year::" + DATE_Lst.DT[1][2] );
}
var para = "DATESS=" + DATE; //? how do I send the whole stack of dates to the PHP file?
AJ.open("POST", "PHP/4_PHP_Check_Dates.php", true);
AJ.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
AJ.send(para);
Here is the PHP file::
$LOGARRY['DT'] = $_POST['DATESS'];
or
$LOGARRY['DT1'] = $_POST['DATESS'][1];
$LOGARRY['DT2'] = $_POST['DATESS'][2];
echo json_encode($LOGARRY);
Thanks.. any help appreciated