Welcome, Guest
Username: Password: Remember me

TOPIC: Percent apples and oranges

Percent apples and oranges 1 year 6 months ago #86902

  • margaret
  • margaret's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 9
  • Karma: 0
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>' );
    });
});
</script>
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.100 seconds
Donation Image