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>
You can declare
tempin the global scope, so that it can be used later in any scope:Alternatively:
Now you can access it like: