dqkxo44488 2019-05-15 00:23
浏览 58

如何添加单选按钮选项的值并显示消息联系表格7

I have a form in CF7 that I would like to assign a numerical value to the Value of each radio choice, then calculate (add) the values of each choice and display a result based on the total.

I have the form structure in place, but need help in calculating the value of the Values, and displaying the result.

Here is a simple structure to explain -

Question 1: Choice A, B, C (A=1, B=2, C=3)
Question 2: Choice A, B, C (A=1, B=2, C=3)
Question 3: Choice A, B, C (A=1, B=2, C=3)
Question 4: Choice A, B, C (A=1, B=2, C=3)
Question 5: Choice A, B, C (A=1, B=2, C=3)

Now a definition has already been set which would mean:

1-7 = Not so good
7-14 = Good
14+ = Excellent

If I select say:

B, C, B, A, B, from Question 1 - 5 respectively, then a score of 10 (2+3+2+1+2) will be calculated and the definition "Good' Will be displayed.

Thank you for any help.

I found this post which is similar, but am not sure if it can work.

    var calc = function() {
    var no = $('#no').val();
    var g1 = $('input[name="g1"]:checked').val();
    var g2 = $('input[name="g2"]:checked').val();

    var simple = no * 10;
    $('#simple').val(simple.toFixed());

    var complex = (no * g1 * 30) + (no * g2 * 100);
    $('#complex').val(complex.toFixed());
}

    $('#no, input[name="g1"], input[name="g2"]').on('change', function() {
    calc();
    });

    <form id="form45" action="" class="">
    <ul>
    <li>
      <input type="radio" name="radio-q1" value="Water">
      <span>Water</span>
    </li>
    <li>
      <input type="radio" name="radio-q1" value="Sportsdrink">
      <span>Sportsdrink</span>
    </li>
    <li>
      <input type="radio" name="radio-q1" value="Milk">
      <span>Milk</span>
    </li>
    </ul>
    <div>
    <button type="submit" class="btn red"><i aria-hidden="true"></i> Calculate Risk</button>
    </div>
    <input type="hidden" name="source" value="">
    </form>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
    • ¥20 怎么用dlib库的算法识别小麦病虫害
    • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
    • ¥15 java写代码遇到问题,求帮助
    • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
    • ¥15 有了解d3和topogram.js库的吗?有偿请教
    • ¥100 任意维数的K均值聚类
    • ¥15 stamps做sbas-insar,时序沉降图怎么画
    • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
    • ¥15 关于#Java#的问题,如何解决?