Hi all, Part of the code i am trying <script language="javascript" type="text/javascript"> ....... var pars = "countryname=<?php echo $countryname;?>"; new Ajax.Updater('formfields', file, { method: 'post', parameters: pars}); ........... </script> Code (markup): When i set $countryname = array('fr','uk','us') i can't get the arrayvalues from countryname. Any ideas?
You are trying to use an php array as an javascript array. var pars = "countryname=<?php echo $countryname;?>"; will be compiled as : "countryname=Array". You can either define a javascript array, or use serialise() on the php array to convert it to string, and then unserialise to change it back to an array.
@bibel, that's exactly what i am trying to do. Stupid of me to not think of serialise(), but that's was because i thought it must be in JS to enable the AJAX request. My solution was the JSON way //make json object... $json = new Services_JSON(); ........ var pars = 'countryname=<?php echo $json->encode($country);?>'; new Ajax.Updater('formfields', file, { method: 'post', parameters: pars}); ...... Code (markup):