【问题标题】:Multiple radiobutton groups with the same names?多个具有相同名称的单选按钮组?
【发布时间】:2017-01-16 02:56:09
【问题描述】:

是否可以在一种形式中拥有多个具有相同名称值的单选按钮组?

我正在做一个由多个(问题)单选按钮组组成的测验,例如:

<div class="question">
                    <p><b>Question 19</b></p>

                    <div class="choices">

                            <input type="radio" name="choice-for-question-98" id="choice-98-1" value="389">
                            <label for="choice-98-1">e duhur </label><br>

                            <input type="radio" name="choice-for-question-98" id="choice-98-2" value="388">
                            <label for="choice-98-2">qëllim</label><br>

                            <input type="radio" name="choice-for-question-98" id="choice-98-3" value="387">
                            <label for="choice-98-3">drejt</label><br>

                            <input type="radio" name="choice-for-question-98" id="choice-98-4" value="386">
                            <label for="choice-98-4">e drejtë</label><br>

                    </div>
                </div>

我想要的是在 POST 中获取“答案”属性列表,但是当我为不同的问题设置相同的名称时,用户只能从所有问题中选择一个单选按钮。

【问题讨论】:

    标签: html radio-button forms


    【解决方案1】:

    没有。

    名称是用于定义单选按钮所属组的机制。

    您可以使用相似但不同的名称,然后在服务器上循环查找它们。

    例如

    name="choice-for-question-98-group-1"
    

    my $choice;
    my $group = 1;
    
    while ($choice = $q->param("choice-for-question-98-group-" . $choice)) {
        do_something_with($choice);
        $group++;
    
    }
    

    【讨论】:

      猜你喜欢
      • 2015-08-27
      • 1970-01-01
      • 1970-01-01
      • 2012-06-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-07-20
      相关资源
      最近更新 更多