Get the average from 5 drop downs in CGFeedback
Posted: Sat Feb 07, 2015 10:36 am
I'm using the CGFeedback module to give feedback on 5 questions that must be rated between 1-5. I added the 5 questions and drop downs as custom fields. They work much like the original default option.
Now I want the page to create 1 rating based on the averages of the 5 custom options, and round it to a whole number between 1-5 , and pass that as the final rating.
http://www.drutengezond.nl/index.php?pa ... jst-hallux
This is the page I'm working on. This is the relevant HTML
The drop down on the bottom with the ID rating (which now is visible but will be hidden), is the one I want to change to get the average of the above 5 fields. I tried to do this with a javascript, but I can't seem to get the values. Hope someone has any idea how to do such a thing. Thanks
Edit: Forgot to mention, the average needs to be parsed as $rating. Currently the rating is get the following way. {html_options options=$rating_options selected=$rating}
Now I want the page to create 1 rating based on the averages of the 5 custom options, and round it to a whole number between 1-5 , and pass that as the final rating.
http://www.drutengezond.nl/index.php?pa ... jst-hallux
This is the page I'm working on. This is the relevant HTML
Code: Select all
<div class="row">
<div class="col-md-4 text-right">
<label for="m54f83field_5">Vraag 1 : Hoe is u ervaring geweest met het wachten:</label>
</div>
<div class="col-md-8">
<select name="m54f83field_5">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
</div>
</div>
<div class="row">
<div class="col-md-4 text-right">
<label for="m54f83field_1">Vraag 2 : Was de uitleg van de behandeling naar wens:</label>
</div>
<div class="col-md-8">
<select name="m54f83field_1">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
</div>
</div>
<div class="row">
<div class="col-md-4 text-right">
<label for="m54f83field_2">Vraag 3 : Hoe was u algemeen gevoel over de behandelaar:</label>
</div>
<div class="col-md-8">
<select name="m54f83field_2">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
</div>
</div>
<div class="row">
<div class="col-md-4 text-right">
<label for="m54f83field_3">Vraag 4 : Zou u de behandelaar aanprijzen bij anderen:</label>
</div>
<div class="col-md-8">
<select name="m54f83field_3">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
</div>
</div>
<div class="row">
<div class="col-md-4 text-right">
<label for="m54f83field_4">Vraag 5 : Was de hygiƫne in orde bij uw behandelaar:</label>
</div>
<div class="col-md-8">
<select name="m54f83field_4">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
</div>
</div>
<div class="row">
<div class="col-md-8">
<select id="m54f83rating" name="m54f83rating">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5" selected="selected">5</option>
</select>
</div>
</div>
Edit: Forgot to mention, the average needs to be parsed as $rating. Currently the rating is get the following way. {html_options options=$rating_options selected=$rating}