简体   繁体   English

带有加权答案的表格

[英]Form with weighted answers

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. 本质上,我们希望引导客户完成20个问题-问卷调查。 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. 一个问题可能以放射状按钮格式具有2、3、4或5个答案,具体取决于他们回答该问题的方式,这将为类别添加一个值。

For Example: Q1: Which of the following will be your priority in 2015? 例如:问题1:您将在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) ) A1:招聘(将(#value)添加到以下类别:产品A(1)产品B(2)产品C(0))A2:培训新人员(添加产品A(2)产品B(0)产品C(0 ))A3:提高绩效较低的公司(添加产品A(0)产品B(2)产品C(1))A4:开设新分支(添加产品A(0)产品B(0)产品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. 我对javascript的了解不多,但是正在学习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. 无需JavaScript。

<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 然后在PHP中,您可以收集

$answers = $_POST["answer"];
$results = [0, 0, 0];
foreach ($answers as $answer) {
  $values = explode(",", $answer);
  for ($p = 0; $p < 3; $p++) {
    $results[$p] += $values[$p];
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM