http://v40z1.cs.cityu.edu.hk:10380/jsp-examples/ajax/restaurant.jsp After I click the menu id and go into the statistics linkage, the whole page cannot refresh well. So, I go back and click the statistics linkage again. The page can show all.
Why the statistics page cannot show well?
I pass 3 arrays and width length to a javascript function. Actually, I would think they do the same.
function drawGraph(g1,g2,g3,gwidth){
// Graph for main dishes
var total=0;
var calpercentage =0;
var calwidth=0;
var output="";
for (i=0;i<g1.length;i++){
total+=parseInt(g1[i][1])
//alert(g[i][1]);
}
output = '<a href=restaurant.jsp>Main Page</a>'
output += '<h2>Main Dishes</h2>'
output +='<table border="0" cellspacing="0" cellpadding="0">'
for (i=0;i<g1.length;i++){
calpercentage=Math.round(g1[i][1]*100/total)
calwidth=Math.round(gwidth*(calpercentage/100))
output+='<tr><td>'+g1[i][0]+' </td><td><img src="'+graphimage+'" width="'+calwidth+'" height="10"> '+calpercentage+'%</td></tr>'
}
output+='</table>'
document.write(output+'<br>Total participants: <b>'+total+'</b><p></p>')
... same as g2 and g3