首页 > 解决方案 > 如果在页面加载禁用按钮

问题描述

使用 Mysql PHP,在一个页面上有一个学生列表,每行都有学生 ID、姓名、生日和几个按钮。如果另一个名为“saral_tcissue”的表中存在student_id,我想禁用以下按钮。如果在 saral_tcissue 中找不到 student_id,用户将能够单击按钮并填写模态表单。学生列表来自具有 student_id 和其他列的表 saral_2016。而 saral_tcissue 表也有 student_id 和其他列。

<td>
  <a class="btn btn-sm btn-primary" type="button" name="nirgam" id="nirgam" 
    data-toggle="modal" 
    data-target="#exampleModal" 
    data-whatever="<?php echo $row['student_id']; ?>">
    <i class="glyphicon glyphicon-pencil"></i>निर्गम
  </a>
</td>

标签: javascriptphpjqueryhtmlmysql

解决方案


也许是这样的:

 $('.btn').each(function(){
    var this_whatever=$(this).attr(data-whatever);
    if(this_whatever=='saral_tcissue'){
        this.disabled = true; 
    }
 });

推荐阅读