View Full Version : How to write a resulting value to a list in new page

07-28-2009, 04:25 PM
In a test I have a long table with about 100 questions. All questions are grouped in, let say, 10 "categories", so every time an user answers a question he adds a value to the corresponding "category".
I would like to show the user his test results in a new page:
Cat. A 12% (or total points)
Cat. B 18% (or total points)
Cat. N 25% (or total points)
A sorted list (ordered from max to min) would be better.

I have ten totals like this
document.getElementById('CatA').value = sum; ... then sum 1, sum 2...
but i am not able to write each sum to a table in a new page.

Please note that I do not have server side technology, php mysql or whatever.
Xml seems to be a possible solution, but it is complicated for me.
Any suggestion?

Philip M
07-28-2009, 06:37 PM
Have a look at:-


07-29-2009, 01:17 PM
Thank you for the hint. The tutorial helped me a lot.
Now my problem is to display the results in a user friendly way.
A CSS styled table with bar graph, as the ones used in poll results, would be great. For example:

<div class="answer_box"><div class="answer_percent" id="answer1_percent" style="width:15%;">&nbsp;</div></div>
<div class="answer_votes">15%</div>

So I need every result as a percentage AND written twice (as above).
As far as I understand from the tutorial you get a location.search string formatted and splitted like this:
mySearch = location.search.substr(1).split("&")

The array of objects created is used in the following function:

function getFromSearch() {
var x = 0
mySearch = location.search.substr(1).split("&")
for (x=0;x<=mySearch.length;x++) {

So, is it possible to change the results in a percentage and write them styled as above css?

07-31-2009, 03:15 PM
After further searches in JavaScript Kit I found Graph-it!, to create graphs out of raw data.
Exactly what I need, a graph with percentages.
My problem now is that the script is based on a multi-dimensional array:

//DEFINE GRAPH VALUES [Item name, absolute value]
var graphx=new Array()
graphx[2]=["ABC News",24]
graphx[3]=["BBC News",52]

On the other end, the getFromSearch function creates a normal array of objects named mySearch. Each will look like this:
and the results are displayed in a text box.

What I am looking for is a method to create two arrays
(one for item name and one for absolute values extracted by mySearch) that automatically fill my graph.
Any idea?
Thanks for your help.