I've done this stuff recently. I need to pass whole arrays betn. php and Javascript (2-way), here is some code:
// PHP var. to JS function arrFromStr (str2convert) { // make an array from string arr = new Array(); var posOfQt1 = str2convert.indexOf('\"'); var posOfQt2 = str2convert.indexOf('\"', posOfQt1+1); i = 0; while(posOfQt1 != -1) { arr[i] = str2convert.substring(posOfQt1+1, posOfQt2); i++; posOfQt1 = posOfQt2; posOfQt1 = str2convert.indexOf('\"', posOfQt1+1); posOfQt2 = str2convert.indexOf('\"', posOfQt1+1); } return arr; } Call this function like this: layerDesStr = '<?=serialize($layerDes[0])?>'; layerDes[0] = arrFromStr(layerDesStr); In case you have a variable don't serialize, just do myJSvar = <?=$myPHPvar?>; JS variables can be sent to PHP by including them in html forms, nothing special about it. > Hello, Folks, > > My apologies if this has been asked a thousand times. I've just joined the > list. > > I can't find any information on passing JavaScript variables to PHP on the > same page (i.e. not through the POST information of a submitted form). Is > this because it's not possible? > > To take the load off the server, I'm trying to do a bunch of string > manipulations and loops in JavaScript and then hand that info off to PHP > once it's done. > > Any insight is appreciated! Thanks, > Jed > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -Pushkar S. Pradhan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php