Percent apples and oranges

4 years 10 months ago #86902 by margaret
margaret created the topic: Percent apples and oranges
I understand this is more Javascript than Limesurvey but..

Q1, get number of people
Q2, how many like apples, how many oranges. Display percent.

I have 10 people from Q1. If you type in that 5 like apples the screen shows
Apples 5 50%

If they see the percent and say - that's not right - and go back and change the answer to 3 the 50% gets shifted over and the screen now shows
Apples 3 30% 50%

How do I get rid of the 50%

Here is my code
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
	var qID = 385;
	var ppl = {INSERTANS:178756X46X370f};
    $("input.text:eq(0)").blur(function() {
	  var appl = Math.floor(100*parseInt($(this).val(), 10)/ppl);
	   $('#answer178756X47X385a').after( '<font size="3">&nbsp;&nbsp;&nbsp; '+appl+' %</font>' );
    $("input.text:eq(1)").blur(function() {
	  var oran = Math.floor(100*parseInt($(this).val(), 10)/ppl);
	   $('#answer178756X47X385o').after( '<font size="3">&nbsp;&nbsp;&nbsp; '+oran+' %</font>' );

Please Log in to join the conversation.

Did you already participate in our customer survey?

Don't miss your chance for great prices.

Please click here to participate:

Start now

Start now!

Just create your account and start using Limesurvey today.

Register now