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 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jul 2009
    Location
    Italy
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to write a resulting value to a list in new page

    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?

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,898
    Thanks
    203
    Thanked 2,530 Times in 2,508 Posts

  • #3
    New to the CF scene
    Join Date
    Jul 2009
    Location
    Italy
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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:
    Code:
    <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:

    Code:
    function getFromSearch() {
    var x = 0
    mySearch = location.search.substr(1).split("&")
    for (x=0;x<=mySearch.length;x++) {
    eval("document.forms.myNewForm."+mySearch[x])
    }
    }
    So, is it possible to change the results in a percentage and write them styled as above css?

  • #4
    New to the CF scene
    Join Date
    Jul 2009
    Location
    Italy
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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:
    Code:
    //DEFINE GRAPH VALUES [Item name, absolute value]
    var graphx=new Array()
    graphx[0]=["CNN",60]
    graphx[1]=["MSNBC",75]
    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:
    myValue=AEIOU
    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.


  •  

    Posting Permissions

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