2016-11-10 5 views
0

テーブルの列selectionの値がnoneではない場合、すべてのボタンを非表示にする必要があります。次に、PHPコード内でjavascriptまたはjqueryを使用してボタンを無効にする方法。提案はjavascriptまたはjquery.I内のPHPコードを使用してこの作業を行うことを歓迎しています。PHPコード内のjavascriptまたはjqueryを使用してボタンを無効にする方法

<?php include("db_conection.php");$sql = "SELECT selection FROM users"; 
$result = $dbcon->query($sql); 
if ($result->num_rows > 0) { 
while($row = $result->fetch_assoc()) { 
$value = $row['selection']; 
if($value !='none'){ 
//need to add jquery or javascript here 
//$('button').attr("disabled", "disabled"); 
//$('button').text('Disabled');  
} 
} 
}?> 
<script type="text/javascript" > 
    // $('button').attr("disabled", "disabled"); 
    // $('button').text('Disabled'); 
    < /script> 

    <tr> 
     <td> 
     <button type="button" class="btn btn-primary" id="q1-1">Q1-1</button > 
    < /td> 
     <td> 
     <button type="button" class="btn btn-primary" id="q2-1">Q2-1</button > 
    < /td> 
     <td> 
     <button type="button" class="btn btn-primary" id="q3-1">Q3-1</button > 
    < /td> 
     <td> 
     <button type="button" class="btn btn-primary" id="q4-1">Q4-1</button > 
    < /td> 
    </tr > 

答えて

0

テキスト要素に最初の値を渡すようにしてください:その後

<input type"text" id="sampleValue" value="<?php echo($value)> // this will put the value in a text element. 

、あなたはそのIDでのjQueryでそれを使用します。

<script type="text/javascript" > 
    if($('#sampleValue')!='none') { 
     $('button').attr("disabled", "disabled"); 
     $('button').text('Disabled'); 
    } 
</script> 
関連する問題