
请问HTML中怎么向javascript中传递数组参数
<html><head><!--LoadtheAJAXAPI--><scripttype="text/javascript"src="https://www.google...
<html>
<head>
<!--Load the AJAX API-->
<scripttype="text/javascript"src="https://www.google.com/jsapi"></script>
<scripttype="text/javascript">
// Load the Visualization API and the piechart package.
google.load('visualization','1.0',{'packages':['corechart']});
// Set a callback to run when the Google Visualization API is loaded.
google.setOnLoadCallback(drawChart);
// Callback that creates and populates a data table,
// instantiates the pie chart, passes in the data and
// draws it.
function drawChart(){
// Create the data table.
var data =new google.visualization.DataTable();
data.addColumn('string','Topping');
data.addColumn('number','Slices');
data.addRows([
['Mushrooms',3],
['Onions',1],
['Olives',1],
['Zucchini',1],
['Pepperoni',2]
]);
// Set chart options
var options ={'title':'How Much Pizza I Ate Last Night',
'width':400,
'height':300};
// Instantiate and draw our chart, passing in some options.
var chart =new google.visualization.PieChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
</script>
</head>
<body>
<!--Div that will hold the pie chart-->
<divid="chart_div"style="width:400;height:300"></div>
</body>
</html>
以上是google chart 的样本程序.
请问下画图那些数据如 (3,1,1,1,2) 如果是想在HTML中用数组传入去, (实际应用上是用其它方式动态获得的.)
该怎么修改HTML, 谢谢! 展开
<head>
<!--Load the AJAX API-->
<scripttype="text/javascript"src="https://www.google.com/jsapi"></script>
<scripttype="text/javascript">
// Load the Visualization API and the piechart package.
google.load('visualization','1.0',{'packages':['corechart']});
// Set a callback to run when the Google Visualization API is loaded.
google.setOnLoadCallback(drawChart);
// Callback that creates and populates a data table,
// instantiates the pie chart, passes in the data and
// draws it.
function drawChart(){
// Create the data table.
var data =new google.visualization.DataTable();
data.addColumn('string','Topping');
data.addColumn('number','Slices');
data.addRows([
['Mushrooms',3],
['Onions',1],
['Olives',1],
['Zucchini',1],
['Pepperoni',2]
]);
// Set chart options
var options ={'title':'How Much Pizza I Ate Last Night',
'width':400,
'height':300};
// Instantiate and draw our chart, passing in some options.
var chart =new google.visualization.PieChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
</script>
</head>
<body>
<!--Div that will hold the pie chart-->
<divid="chart_div"style="width:400;height:300"></div>
</body>
</html>
以上是google chart 的样本程序.
请问下画图那些数据如 (3,1,1,1,2) 如果是想在HTML中用数组传入去, (实际应用上是用其它方式动态获得的.)
该怎么修改HTML, 谢谢! 展开
3个回答
展开全部
你可以写<script>var xxx=……</script>然后js里用xxx变量代替动态内容 更好的办法是使用js中的ajax技术来请求网页数据并解析处理
追问
问题是怎么把动态的内容传入 xxx 中 ?
追答
你是用什么语言?ASP?php?还是
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
比如一个触发事件
html onclick="demo(3,1,1,1,2)"
js function demo(obj1,obj2,obj3,obj4,obj5){alert obj1};
html onclick="demo(3,1,1,1,2)"
js function demo(obj1,obj2,obj3,obj4,obj5){alert obj1};
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
传入数组首地址 都一样滴
追问
问题是怎么在HTML里面定义个数组,然后怎么调用js里面的function ?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询