- Posts: 9
- Thank you received: 0
Percent apples and oranges
5 years 6 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
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"> '+appl+' %</font>' );
});
$("input.text:eq(1)").blur(function() {
var oran = Math.floor(100*parseInt($(this).val(), 10)/ppl);
$('#answer178756X47X385o').after( '<font size="3"> '+oran+' %</font>' );
});
});
</script>
Please Log in or Create an account to join the conversation.