Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Nov 2010
    Location
    canada
    Posts
    131
    Thanks
    51
    Thanked 0 Times in 0 Posts

    Functions and show functions

    Ok here is what I have so far, my ending part of my Call Function I think is ok.

    for my main function. I think I misplaced the { and }

    I will show you all the codes I have

    for my main function

    this is what I have


    I think I did misplace something but I can not pin point where that one small things should be


    Code:
    unction showResults(race,name,party,votes)
    	{ 					// script element to display the results of a particular race
    var totalV = totalVotes(votes);
    document.write("<h2>" + race + "</h2>");
    document.write("<table cellspacing='0'>");
    document.write("<tr>");
    document.write("<th>Candidate</th>");
    document.write("<th class ='num'>Votes</th>");
    document.write("<th class='num'>%</th>");
    document.write("</tr>");
    	}
    	
    	
    for (var i=0; i < name.length; i++)
    {
    document.write("<tr>");
    document.write("<td>" name[i] + "(" + party[i] + ")</td>");
    document.write("td class='num'>" + votes[i] + "</td>");
     
    var percent=calcPercent(votes[i], totalV)
     
    document.write("<td class='num'>(" + percent +"%)</td>");
     
    createBar(party[i],percent)
    document.write("</tr>");
    }
    document.write("</table>");
    }
    </script>
    Just wondering if i misplaced any ; or { or } anywhere suggestions?


    Here is my call function
    Code:
    <script type="text/javascript">
    	
    showResults(race[0],name1,party1,votes1);
    showResults(race[1],name2,party2,votes2);
    showResults(race[2],name3,party3,votes3);
    showResults(race[3],name4,party4,votes4);
    showResults(race[4],name5,party5,votes5);
      
    </script>
    I been going over this, I can not seem to figure out what { i might be missing?
    Thanks
    Last edited by worldtraveller; 11-22-2010 at 06:47 PM.

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,079
    Thanks
    203
    Thanked 2,542 Times in 2,520 Posts
    worldtraveller - you seem to have a hide like an elephant. One more time - please do not use this forum for remedial teaching and finding simple errors in your code. It ought to be obvious what your problem is - carelessness as usual.

    Once again - in future use your error console or Firebug. It would throw up your typos at once.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •