Hello People please find my code below as you can see iam trying to pass php array values to js function if i run this scipt i get 3 alerts parameter0=1,parameter1=2 and parameter2=3 differently...what iam trying to do is i need to save parameter0,parameter1 and parameter3 so that i can pass it one more function....please help me to do this.....
<script type="text/javascript">
function mufunc(a)
{
var temp = new Array();
dump(temp);
temp = a.split('~');
var parameter;
for(i=0;i<temp.length;i++)
{
alert('parameter'+i+'='+temp[i]);
}
//alert('sri'+i+'='+temp[i]);
}
</script>
<?php
$a = array('1','2','3');
$b = implode("~",$a);
?>
<a href="javascript:void(0)" onClick="mufunc('<?php echo $b; ?>')">Click Here</a>
<?php echo implode(',',$b);
, and in your JS function:var parameters= Array.prototype.slice.apply(arguments,[0]);
, and paramters will be an array, that looks like this:[1,2,3]
. Job done – Elias Van Ootegem Nov 27 '12 at 17:23