Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/294.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 灰显HTML表单元素_Php_Mysql_Html - Fatal编程技术网

Php 灰显HTML表单元素

Php 灰显HTML表单元素,php,mysql,html,Php,Mysql,Html,我想让用户选择一个“行”来提交报告,并请求报告类型。如何将单选按钮放在表的第一列中,并且选择哪个是通过提交按钮发送到下一页的活动行?如果您想在纯PHP中执行此操作,我想您可以这样做: <form action="ascript.php" action="post"> <table> <tr> <td><input type="radio" value="row1" name="theRadioB

我想让用户选择一个“行”来提交报告,并请求报告类型。如何将单选按钮放在表的第一列中,并且选择哪个是通过提交按钮发送到下一页的活动行?

如果您想在纯PHP中执行此操作,我想您可以这样做:

<form action="ascript.php" action="post">
    <table>
        <tr>
            <td><input type="radio" value="row1" name="theRadioButton" /></td>
            <td><input type="text" name="row1textfield" /></td>
        </tr>
        <tr>
            <td><input type="radio" value="row2" name="theRadioButton" /></td>
            <td><input type="text" name="row2textfield" /></td>
        </tr>
        <tr>
            <td><input type="radio" value="row3" name="theRadioButton" /></td>
            <td><input type="text" name="row3textfield" /></td>
        </tr>
    </table>
</form>

ascript.php

<?php 
    if ($_POST['theRadioButton'] == "row1") {
        echo $_POST['row1textfield'];
        // Handle row 1 ..
    }
    else if ($_POST['theRadioButton'] == "row2") {
        echo $_POST['row2textfield'];
        // Handle row 2 ..
    }
    else if ($_POST['theRadioButton'] == "row3") { 
        echo $_POST['row3textfield'];
        // Handle row 3 ..
    }
?>


但是,如果您愿意使用一些jQuery,您可以将textfields命名为相同的名称,并禁用不打算使用的字段。这里有一个小问题:

如果您想在纯PHP中实现它,我想您可以这样做:

<form action="ascript.php" action="post">
    <table>
        <tr>
            <td><input type="radio" value="row1" name="theRadioButton" /></td>
            <td><input type="text" name="row1textfield" /></td>
        </tr>
        <tr>
            <td><input type="radio" value="row2" name="theRadioButton" /></td>
            <td><input type="text" name="row2textfield" /></td>
        </tr>
        <tr>
            <td><input type="radio" value="row3" name="theRadioButton" /></td>
            <td><input type="text" name="row3textfield" /></td>
        </tr>
    </table>
</form>

ascript.php

<?php 
    if ($_POST['theRadioButton'] == "row1") {
        echo $_POST['row1textfield'];
        // Handle row 1 ..
    }
    else if ($_POST['theRadioButton'] == "row2") {
        echo $_POST['row2textfield'];
        // Handle row 2 ..
    }
    else if ($_POST['theRadioButton'] == "row3") { 
        echo $_POST['row3textfield'];
        // Handle row 3 ..
    }
?>


但是,如果您愿意使用一些jQuery,您可以将textfields命名为相同的名称,并禁用不打算使用的字段。这里有一把小提琴:

我认为安德烈亚斯走上了正确的道路,但它并没有发挥应有的作用。这应该更好一些:

<?php 
blah ...

echo <<<HTML
    <form action="handler.php" action="post">
        <table>
HTML;

foreach ($rows as $row)
{
    $id = $row['id'];
    $text = $row['text'];  // escape this unless you know it's safe

    echo <<<HTML
        <tr>
            <td><input type="radio" value="$id" name="theRadioButton" /></td>
            <td><input type="text" name="textfield_$id" value="$text" /></td>
        </tr>
HTML;
}

echo <<<HTML
    </table>
</form>
HTML;

我认为安德烈亚斯走上了正确的道路,但它并没有发挥应有的作用。这应该更好一些:

<?php 
blah ...

echo <<<HTML
    <form action="handler.php" action="post">
        <table>
HTML;

foreach ($rows as $row)
{
    $id = $row['id'];
    $text = $row['text'];  // escape this unless you know it's safe

    echo <<<HTML
        <tr>
            <td><input type="radio" value="$id" name="theRadioButton" /></td>
            <td><input type="text" name="textfield_$id" value="$text" /></td>
        </tr>
HTML;
}

echo <<<HTML
    </table>
</form>
HTML;