Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

AJAX Refresh

 
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic