I need help creating a weighted form - which seems to means a lot of things to different people. Essentially, we want to walk a customer through a 20 question - questionnaire. A Question may have 2, 3, 4, or 5 answers in a radial button format, depending on how they answer that question, it would add a value to a category.
For Example: Q1: Which of the following will be your priority in 2015? A1: Recruiting (Adds (#value) to following categories: Product A (1) Product B (2) Product C (0) ) A2: Training new reruits (Adds Product A (2) Product B (0) Product C (0) ) A3: Increasing performance of lower performers ( Adds Product A (0) Product B (2) Product C (1) ) A4: Opening new branches (Adds Product A (0) Product B (0) Product C (2) )
At the end of the quiz, a suggestion would be made of a certain product based on the totals for each category.
I do not have much knowledge of javascript, but am learning PHP. I am much better at reading and editing various languages than I am writing my own, so any suggestions on how to carry this task out would be great.
Thanks.
No JavaScript needed.
<form method="post" action="submit.php">
...
Question 1:
<input type="radio" name="answer[0]" value="1,2,0">
<input type="radio" name="answer[0]" value="2,0,0">
...
</form>
and then in PHP, you can collect
$answers = $_POST["answer"];
$results = [0, 0, 0];
foreach ($answers as $answer) {
$values = explode(",", $answer);
for ($p = 0; $p < 3; $p++) {
$results[$p] += $values[$p];
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.