|
 |
|
สอบถาม JSON จาวาคริปครับ ทำยังไงให้สามารถถึงค่า การแสดงผลข้อมูล array ให้ออกมาเป็นแบบวนลูปได้ครับ |
|
 |
|
|
 |
 |
|
สอบถามครับ ผมต้องมีค่าที่ส่งมาจากปุ่ม onclick ให้กับฟังชัน จาวาคริป ซึ่งค่าที่ส่งมาเป็น Array ที่ enclodec ดังนี้ครับ
$dataValue2 = json_encode($dataValue);
$seriename2 = json_encode($seriesname);
ส่วน php <input type="button" onclick=chart('<?=$dataValue2?>,<?=categoryArray2?>,<?= $seriesname2?>')>
ซึ่งใน ฟังชั่น จาวาคริป สำหรับสร้างกราฟเป็นแบบนี้ครับ
Code
function chart_scrollcolumn(sid, chart_type, categoryArray2, head, ansArray2, seriesname2, mr_num,dataval)
{
$("#chartContainer" + sid).insertFusionCharts({
type: chart_type,
width: "900",
height: "450",
dataFormat: "json",
dataSource: {
"chart": {
"caption": head,
"bgcolor": "ffffff,ffffff",
"showlabels": "1",
"showvalues": "0",
"showborder": "0",
"decimals": "0",
"numberprefix": "$"
},
"categories": [
{
"category": [
categoryArray2
]
}
],
"dataset": [
{
"seriesname": seriesname2[0],
"color": "AFD8F8",
"data": [
ansArray2[0]
]
},
{
"seriesname": seriesname2[1],
"color": "F6BD0F",
"data": [
ansArray2[1]
]
},
{
"seriesname":seriesname2[2],
"color": "8BBA00",
"data": [
ansArray2[2]
]
}
]
}
});
}
ผมอยากให้
Code
{
"seriesname": seriesname2[0],
"color": "AFD8F8",
"data": [
ansArray2[0]
]
},
มันออกมาแบบวนลูป คล้าย ๆ
Code
for(var i;i<=100;i++)
{
"seriesname": seriesname2[i],
"color": "AFD8F8",
"data": [
ansArray2[i]
}
จะต้องทำยังไงครับ
Tag : PHP, JavaScript, Ajax, jQuery

|
|
 |
 |
 |
 |
Date :
2013-11-19 22:18:56 |
By :
ณัฐพงษ์ |
View :
702 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
|
|

|
Load balance : Server 03
|