I m having problem in using the php array values in javascript. I m not very good in javascript so i need a support from u.. $pr[]=array(date('y/m/d',strtotime($rev_date)),$w_s['status_percent']);
this is the php array i m using. I need to use its values in the following javascript code
<script id="source" language="javascript" type="text/javascript">
$(function () {
var datasets = {
"a": {
label: "A",
data: [[1988, 483994], [1989, 479060], [1990, 457648], [1991, 401949], [1992, 424705], [1993, 402375], [1994, 377867], [1995, 357382], [1996, 337946], [1997, 336185], [1998, 328611], [1999, 329421], [2000, 342172], [2001, 344932], [2002, 387303], [2003, 440813], [2004, 480451], [2005, 504638], [2006, 528692]]
},
"B": {
label: "B",
data: [[1988, 218000], [1989, 203000], [1990, 171000], [1992, 42500], [1993, 37600], [1994, 36600], [1995, 21700], [1996, 19200], [1997, 21300], [1998, 13600], [1999, 14000], [2000, 19100], [2001, 21300], [2002, 23600], [2003, 25100], [2004, 26100], [2005, 31100], [2006, 34700]]
}
I need values of $pr in Label: "A" of javascript. the way i used for it is given below but its not working :(
<?php
function data_sets() {
$j=count($pr);
foreach ($pr as $row) {
echo "[";
$i=0;
foreach ($row as $v){
$i++;
//echo " $v ";
echo " 1000 ";
if($i==1){
echo ",";
}
}
$j--;
if($j!=0){
echo "],";
}
else{
echo "]";
}
}
}
<script id="source" language="javascript" type="text/javascript">
$(function () {
var datasets = {
"a": {
label: "A",
data: [<?php echo "data_sets()"; ?>]
},
"B": {...... etc
?>
Plz help me :(