【问题标题】:Button not display its value inside "eco" tag按钮不在“eco”标签内显示其值
【发布时间】:2018-09-03 18:44:13
【问题描述】:

while(($res =  $statement->fetch(PDO::FETCH_ASSOC)) && ($c<$row)) {
    $c=$c+1;
    echo"<tr style='color:#00284d;font-size:15px;';>
                            <td style='background-color:#00284d;color:white;width:30px;'>{$c}</td>
                            <td>{$res['user_id']}</td>
                            <td>{$res['user_name']}</td>
                            <td>{$res['user_type']}</td>
                            <td><button type='button' name='edit' id='edit' **value='".$res['user_id']."'** class='btn btn-warning btn-sm' style='width:72px;'/></td>
                            <td><button type='button' name='delete' id='delete' value='".$res['user_id']."'  class='btn btn-danger btn-sm' onclick='asd();' style='width:72px;'/></td>
    // not display button inside value, always display 1 (display mean actually i checked what is the its value using javascript) 
    </tr>";
    }
}
?>

【问题讨论】:

    标签: php html pdo


    【解决方案1】:

    你需要把文字放在&lt;button&gt;&lt;/button&gt;标签之间

    <button type='button' name='edit' id='edit' **value='".$res['user_id']."'** class='btn btn-warning btn-sm' style='width:72px;'>EDIT</button>
    
    <button type='button' name='delete' id='delete' value='".$res['user_id']."'  class='btn btn-danger btn-sm' onclick='asd();' style='width:72px;'>
        DELETE
    </button>
    

    【讨论】:

      【解决方案2】:

      只需像其他代码一样更改这段代码。

      这是要更改的代码

      <td><button type='button' name='edit' id='edit' **value='".$res['user_id']."'** class='btn btn-warning btn-sm' style='width:72px;'/></td>
      <td><button type='button' name='delete' id='delete' value='".$res['user_id']."'  class='btn btn-danger btn-sm' onclick='asd();' style='width:72px;'/></td>
      

      像这样

      <td><button type='button' name='edit' id='edit' class='btn btn-warning btn-sm' style='width:72px;' value='{$res['user_id']}'>{$res['user_id']}</button> </td>
      <td><button type='button' name='delete' id='delete' value='{$res['user_id']}'  class='btn btn-danger btn-sm' onclick='asd();' style='width:72px;' value='{$res['user_id']}'>{$res['user_id']}</button></td>
      

      【讨论】:

      • 谢谢,显示按钮文本,但是当按钮单击时我如何获取每个按钮值(显示的文本)。(按钮具有相同的名称)(因为我不会访问 if(isset($_POST[buttonname] ) 方法)
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-07-27
      • 2017-12-31
      • 1970-01-01
      • 2014-04-11
      • 2017-06-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多