Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
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
Old 11-14-2012, 06:13 PM   PM User | #2
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,615
Thanks: 5
Thanked 865 Times in 842 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
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.
__________________
Don’t click this link!
VIPStephan is offline   Reply With Quote
Old 11-14-2012, 06:46 PM   PM User | #3
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
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.
TheTrashcanMan is offline   Reply With Quote
Reply

Bookmarks

Tags
form, html, javascript, likert

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:33 AM.


Advertisement
Log in to turn off these ads.