如果设置单选按钮如何获取

时间:2018-01-17 17:10:17

标签: php html

所以我在html文档中有3个单选按钮。然后,我只是尝试获取是否设置了其中一个按钮,然后为其中一个勾选按钮打印消息。 它们都是一种形式。 我的按钮是:

echo "<table border=0>";
                echo "
                    <tr>
                        <td>
                            <input type=radio name=sg value=admin /> Administrator
                        </td>
                    </tr>
                ";
                echo "
                    <tr>
                        <td>
                            <input type=radio name=sg value=operator /> Operator
                        </td>
                    </tr>
                ";
                echo "
                    <tr>
                        <td>
                            <input type=radio name=sg value=member checked=checked /> member
                        </td>
                    </tr>
                ";
        echo "</table>";

我尝试获取它们的方式是:

if(isset($_GET['member'])) {
            echo "m is set!";
        }
        if(isset($_GET['admin'])) {
            echo "a is set!";
        }
        if(isset($_GET['operator'])) {
            echo "op is set!";
        }

这不会打印任何内容,意味着if子句中的所有语句都不成立。 我如何得到它们?

1 个答案:

答案 0 :(得分:2)

您输入的输入值不正确,如下所示:

val laidOutRectangles = mutableListOf<Rectangle>() // Rectangle is defined by x1, y1, x2, y2
val ranges = mutableListOf<Range>() // Range just has lower and upper bounds
val width = 100

ranges.sortedByDescending { it.first }.forEach { range ->
    // Get top and bottom of range
    val lower = range.first
    val upper = range.second

    // Work out overlapping rectangles
    var overlappingRectangles = 0
    laidOutRectangles.forEach { rectangle ->
        if ((lower >= rectangle.y1 && lower <= rectangle.y2) ||
                (upper >= rectangle.y1 && upper <= rectangle.y2)) {
            overlappingRectangles++
        }
    }

    val rectangleWidth = (width / (overlappingRectangles + 1)).toInt()

    val newRectangle = Rectangle(0, lower, rectangleWidth, upper)
    laidOutRectangles.add(newRectangle)

    var repositionedRectangles = 0
    laidOutRectangles.filter {
        ((lower >= it.y1 && lower <= it.y2) ||
                (upper >= it.y1 && upper <= it.y2))
    }.sortedByDescending {
        Math.abs(upper - lower)
    }.forEach { rectangle ->
        rectangle.width = rectangleWidth
        rectangle.x1 = (rectangleWidth * (repositionedRectangles + 1)).toInt()
        rectangle.x2 = (rectangle.x1 + rectangleWidth)
        repositionedRectangles++
    }
}

而不是HTML元素的名称,如下所示:

if(isset($_GET['member']))