【问题标题】:How to get the submit button to work with my checkboxes如何让提交按钮与我的复选框一起使用
【发布时间】:2021-01-22 20:07:23
【问题描述】:

我已经在这工作了几个小时了,我似乎无法让复选框做任何其他事情,而不是在外观上。我需要它让用户输入他们是哪一个,然后按提交按钮以获取他们输入的内容。

<tr>
                    <td>
                        <input type = 'checkbox' name = 'area2d' value = 'area' id = 'area'>
                        <label for = 'area'> Area </label>
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type = 'checkbox' name = 'perimeter' value = 'perimeter' id = 'perimeter'>
                        <label for = 'perimeter'> Perimeter </label>
                    </td>
                    <td>

                        
                    </td>
                    <td>
                        <input type = 'submit' name = 'area2d' id = 'area' value = 'Submit Query'>
                        <input type = 'submit' name = 'perimeter' id = 'perimeter' value = 'Submit Query'>
                        <input type= 'reset' name= 'Reset' id= 'Reset' value= 'Reset'>
                    </td>
                </tr>

一切都很好,但我似乎无法弄清楚如何正确地将它们链接在一起。

<tr>
                    <td>
                        <input type = 'radio' name = 'shape' value = 'circle' id = 'shapeT'>
                        <label for = 'shapeT'> Triangle </label>
                    </td>
                    <td>
                        <label for = 'heightBox'> Height </label>
                    </td>
                    <td>
                        <input type = 'number' name = 'height2d' id = 'heightBox'>
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type = 'radio' name = 'shape' value = 'circle' id = 'shapeR'>
                        <label for = 'shapeR'> Rectangle </label>
                    </td>
                    <td>
                        <label for = 'widthBox'> Width </label>
                    </td>
                    <td>
                        <input type = 'number' name = 'width2d' id = 'widthBox'>
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type = 'radio' name = 'shape' value = 'circle' id = 'shapeC'>
                        <label for = 'shapeC'> Circle </label>
                    </td>
                    <td>
                        <label for = 'radiusBox'> Radius </label>
                    </td>
                    <td>
                        <input type = 'number' name = 'radius2d' id = 'radiusBox'>
                    </td>
                </tr>

【问题讨论】:

    标签: html math submit area brackets


    【解决方案1】:

    您不希望表单元素具有重复的name 属性。 This post 表示只有具有给定 name 的最后一个元素将在 POST 对象中可用

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-09-10
      • 1970-01-01
      • 1970-01-01
      • 2023-02-15
      • 2015-12-02
      • 2013-08-12
      相关资源
      最近更新 更多