0 votes
in SoSci Survey (English) by s133453 (165 points)

Hi,
I am wondering, if it is possible to add a CO2-calculator to one page, where the participants can put in their recent flight hours (the time spent flying in the last year). On the next page there should be the output: "the hours spent flying X 0.24 t CO2" to get the total amount of CO2 produced by flying over the last year.

So if a person was flying 10 hours, the output should be: "You emitted 2.4 t CO2 in the last year."

The next thing would be to put that number in contrast to an average amount of CO2 emitted, like: "You emitted 2.4 t CO2 in the last year. That is two times the average amount of CO2 emitted in Germany by flying."

I hope you understood what I am trying to do. Looking forward to answers!

Thx
Manuel

1 Answer

+1 vote
by SoSci Survey (328k points)

Yes, you can do calculations eithin in JavaScript (when required on the same page) or in PHP, when they are required on the next page. Simple example:

$hours = value('AB01_01');
$co2 = 0.24 * $hours;
replace('%co2%', sprintf('%1.1f', $co2));

html('<p>You emitted %co2% t CO2 in the last year.</p>');

It is more elegant to use the placeholders in texts or questions, but this is the general usage. If you wonder about the sprintf() function: This is just to take care of the decimal formatting.

Willkommen im Online-Support von SoSci Survey.

Hier bekommen Sie schnelle und fundierte Antworten von anderen Projektleitern und direkt von SoSci Survey.

→ Eine Frage stellen


Welcome to the SoSci Survey online support.

Simply ask a question to quickly get answers from other professionals, and directly from SoSci Survey.

→ Ask a Question

...