Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6196405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:38:17+00:00 2026-05-24T03:38:17+00:00

In my Javascript Multi-Dimensional Arrays, it stores 3 values: NAME, ROUND, No. of Vote

  • 0

In my Javascript Multi-Dimensional Arrays, it stores 3 values: NAME, ROUND, No. of Vote

Sample data:

NAME| ROUND| No. of Vote

Evan | 1 | 2

John | 1 | 1

Mary | 1 | 3

Evan | 2 | 4

John | 2 | 1

I want to display the Voting result on screen with percentage (based on ROUND), Just Like that:

ROUND 1

Evan – 2 Votes (33.3%)

John – 1 Vote (16.7%)

Mary – 3 Votes (50%)

ROUND 2

Evan – 4 Votes (80%)

John – 1 Vote (20%)

Thanks,
Joe

The following is my javascript code:.

function rpt_result(){
var temp = '';
var l_temp = '';
var html = '';
var num = obj('remain').value;
var total = 0;
var tmp_round = 0;
html += '<html>';
html += '<head><title>Voting Result</title>';
html += '</head>';
html += '<body>';
html += '<table width="760" align="center"><tr><td align="center"><h2>' + obj('ta_title').value + '</h2></td></tr>';
html += '<tr><td>&nbsp;</td></tr>';
html += '<tr><td align="center">Each Round Results</td>';
html += '</table>';
html += '<div id="button" style="width:760px;margin-top:20px;margin-bottom:20px;"><input type="button" value="Print" onmouseup="window.print()" style="float:right;" /></div>';
html += '<table width="760" align="center" border="0">';
html += '<tr>'
html += '<td><b><u>Winner:</b></u></td>';
html += '</tr>';
html += '<tr><td>';
for (i = 0; i < winnerArray.length; i++) {
    temp = winnerArray[i].split('|', 3);
    vote = temp[0];
    name = temp[1];
    round = temp[2];
    html += '(The' + num2Chi(round) + 'Round) ' + name + ' ' + vote + 'Votes' + '<br />'; 
}
html += '</td></tr>';
html += '<tr><td>&nbsp;</td></tr>';
html += '<tr>'
html += '<td><b><u>Detail Voting Result:</b></u></td>';
html += '</tr>';
html += '<tr><td>';

for (i = 0; i < wholeArray.length; i++) {
    w_temp = wholeArray[i].split('|', 4);
    w_vote = w_temp[0];
    w_name = w_temp[1];
    w_round = w_temp[2];
        html += '<font color="red">(The' + num2Chi(w_round) + 'Round) ' + w_name + ' ' + w_vote + ' Votes </font><br />';
}
html += '</td></tr>';

html += '</table>';
html += '</body>';
html += '</html>';
var x = window.open('', 'printList', "location=0,menubar=0,scrollbars=1,status=0,toolbar=0,resizable=1,width=800,height=600");
x.document.write(html);
x.document.close();
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T03:38:19+00:00Added an answer on May 24, 2026 at 3:38 am

    You need 2 loops, one to count ALL the votes, and set it into a sum variable, and the other the calculate the percentage of each.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have several situations where I need to pass multi-dimensional PHP arrays into Javascript/jQuery.
I want to convert a multi-dimensional PHP array to JavaScript and found this script
What is the best way of converting a multi-dimensional javascript array to JSON?
How do I generate page numbers for a multi page data set using javascript?
I'm generating a multi-dimensional array in javascript that looks like this (this is the
I need to store a multi-dimensional associative array of data in a flat file
I have a multi-timezone web application that stores all of the datetime values in
I want to build a multi tenent cloud app. My stack is javascript /
Reading through this question on multi-threaded javascript, I was wondering if there would be
Modern browsers have multi-tab interface, but JavaScript function window.showModalDialog() creates a modal dialog that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.