如果列中有值(如果在moda中),如何禁用<input“text”=“”/>

时间:2017-03-31 19:48:23

标签: php

您好GoodMorning(在菲律宾):)

    I want to disable the <input ="text"> if there is a value in the dedicated column

        <?php
    $stmt = $db_con->prepare("SELECT * FROM userinfo WHERE role='student' AND gradelvl='7' AND sectionname='studid' ORDER BY lrnno ASC");
    $stmt->execute();
    $row=$stmt->fetch(PDO::FETCH_ASSOC)
    ?>
    <form action="71stgmodalaction.php" method="POST" class="form-horizontal">
        <div id="1stgrade7" class="modal fade">
        <div class="modal-dialog">
        <div class="modal-content">
        <div class="modal-header">
        <div class="form-group">      

    <input type='text' name='id' value='studid'; ?>' />
            <h2 class="modal-title"><div align="center">Please Fill Correctly</div></h2>

    <div class="modal-header">
            <h4 class="modal-title"><div align="center">1st Grading Result</div></h4>
              </div>

    <div class="modal-body"><div align="left">
        <b>Filipino:</b><input type="text" class="resizedTextbox" name="c71stgfilipino" >
    </div>           
    <div class="modal-footer">   
        <button type="submit" name="submit71st"  class="btn btn-success">Save changes</button> 
    </div>
    </div>
    </div>
    </div>
    </div>

    </form>

以下是我更新列

的操作
 <?php

    if($_POST)
    {

    $id = $_POST['id'];
    $c7finalgfilipino = $_POST['c7finalgfilipino'];     

    $stmt = $db_con->prepare("UPDATE userinfo SET c7finalgfilipino=:qc7finalgfilipino WHERE id=:id");
    $stmt->bindParam(":qc7finalgfilipino", $c7finalgfilipino);

    $stmt->bindParam(":id", $id);

    if($stmt->execute())
    {
        echo "Successfully updated";

    }
    else{
        echo "Query Problem";
    }
}

?>

如果该文本中的值为输入类型=“文字”名称=“c71sthfilipino”,该怎么办?

希望能理解我说的话,对不起我的英语语法:) 提前致谢

2 个答案:

答案 0 :(得分:1)

你可以像这样禁用它

<input type="text" 
        class="resizedTextbox" 
        name="c71stgfilipino" 
<?php echo isset($row['column']) ? 'disabled' : '' ?> >

答案 1 :(得分:1)

我相信你要做的是JavaScript(JQuery让你更容易)。

$(function(){
   var elem = $('input[name="c71sthfilipino"]');
   if ( !$(elem).val() ){
      elem.prop('disabled', true);
   }
})