Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing multidimensional JS array to PHP (ajax)

Status
Not open for further replies.

cfgcjm

Programmer
Oct 30, 2007
21
US
I've created a multidimensional array in js and I want to pass it to PHP through Ajax and have no clue how to so i'm looking for some direction

Array construction & Ajax call:
Code:
function save(numStd){
	
//Find Selected Class
var all = document.all ? document.all :
document.getElementsByTagName('*');
var elements = new Array();
for (var e = 0; e < all.length; e++)
if (all[e].className == 'active')
var currentClass=all[e].id; 
	
var sendParams=encodeURIComponent(numStd)+"&param1="+encodeURIComponent(currentClass);

//Declare array
var array = new Array(3);
for (var i = 0; i < numStd; i++) {
	array[i] = ['', ' ', ' '];
}

//fill array
for (var j = 1; j <= numStd; j++) {
	var ln = document.getElementById("LastName"+j).value;
	var fn = document.getElementById("FirstName"+j).value;
	var ag = document.getElementById("Age"+j).value;
	var h=j-1;
	array[h][0] = ln;
	array[h][1] = fn;
	array[h][2] = ag;
}


        var urlNewStd = "/phpscripts/saveNewStd.php?param=";
	http.open("GET", urlNewStd + escape(numStd)+"&param1="+escape(currentClass)+XXX ARRAY HERE XXX, true);
	document.getElementById("studentresult").innerHTML="<img src='/images/ajax-loader.gif' style='margin:50px 0 0 110px;'/>";
	http.onreadystatechange = handleHttpResponseNewStd;
	http.send(null);*/
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top