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 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Oct 2012
    Location
    Hillsboro, Oregon
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Creating a likert scale form, need help with processing data.

    Alright,

    So I have built the likert form and a script to process a the score. Only problem is that I need help finishing it all and I need to have the score be displayed on the same as the form/likert form they just completed. Here is and example of the code I am using: (shorted for readability)

    Code:
    <div class="test">
        <form action="" method="POST" id="form1">
             1. Rate your level of visibility into information you need to proactively 
                 and profitably run your business:</br>
                 <span class="answers">
                 <input type="radio" name="q1" value="1"/>
                 Zero visibility<br/>
                 <input type="radio" name="q1" value="2"/>
                 20 percent<br/>
                 <input type="radio" name="q1" value="3"/>
                 40 percent<br/>
                 <input type="radio" name="q1" value="4"/>
                 60 percent<br/>
                 <input type="radio" name="q1" value="5"/>
                 80 percent<br/>
                 <input type="radio" name="q1" value="6"/>
                 100 percent <br/>
                 </span>
                 <br/>
    
              2. To stay on top of and improve your business, you (check all that apply):<br/>
                 <span class="answers">
                 <input type="radio" name="q2" value="1"/>
                 Check a daily dashboard that shows how you perform against key performance indicators<br/>
                  <input type="radio" name="q2" value="1"/>
                  Are automatically notified by your software system (via test or email) when certain conditions, such as a job’s profit threshold, aren’t met<br/>
                  <input type="radio" name="q2" value="1"/>
                  Analyze your performance across projects and against industry benchmarks<br/>
                  <input type="radio" name="q2" value="1"/>
                  Spot trends and forecast costs and performance.<br/>
                  <input type="radio" name="q2" value="1"/>
                  Access key information while on the road using mobile devices <br/>
                 </span>
          </form>
    
          <input type='button' value='score' onclick="score()"/>
    
          <script type="text/javascript">
                function el(tid) {return document.getElementById(tid);}  
    	    function score(){
    		var ems = el("form1").elements;
    		var buff=[], count=0, total=0;
    		for(var i=0, mx=ems.length;i<mx;i++){
    		if(ems[i].checked){ total+=Number(ems[i].value); count++; }
    						}
    		alert("total: "+total+" ; Avg: "+ (total/count).toFixed(1) );
    						}
    	</script>
    </div>

    Any help would be greatly appreciated.
    Last edited by TheTrashcanMan; 11-14-2012 at 06:48 PM. Reason: added code BB tags

  • #2
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,797
    Thanks
    6
    Thanked 1,023 Times in 996 Posts
    If you post any code please put it in between [CODE][/CODE] tags. It makes scanning your posts much easier. You can do this by clicking the small ‘#’ icon above the reply field.

  • #3
    New to the CF scene
    Join Date
    Oct 2012
    Location
    Hillsboro, Oregon
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by VIPStephan View Post
    If you post any code please put it in between [CODE][/CODE] tags. It makes scanning your posts much easier. You can do this by clicking the small ‘#’ icon above the reply field.
    Sorry, didn't see that till after I had already clicked submit.


    Also, I would like to add if anyone could also help me have the "alert" display the answer as a percentage. This percentage shows them how visible their business is.


  •  

    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
    •