View Single Post
Old 11-14-2012, 05:51 PM   PM User | #1
TheTrashcanMan
New to the CF scene

 
Join Date: Oct 2012
Location: Hillsboro, Oregon
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
TheTrashcanMan is an unknown quantity at this point
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
TheTrashcanMan is offline   Reply With Quote