如何在MATERIALIZE CSS中更改SELECT标记的值。我正在尝试显示从数据库存储的所选项目。我尝试在选择的末尾添加.material_select(),但它仅检索行中的最后一个。如何显示每次尝试?到目前为止,这是我尝试过的。

  $(function() {

    <?php
    $q  =  $db->query("SELECT buildingID, buildingName,building_projectID, floorNumber FROM tblBuilding");
      while($r = $q->fetch(PDO::FETCH_ASSOC)){
          $buildingID = $r['buildingID'];
          $buildingName = $r['buildingName'];
          $building_projectID = $r['building_projectID'];
          $floorNumber = $r['floorNumber'];
        $t = $db->query("select projectName from tblProject where projectID  = $building_projectID ");
        while($u = $t->fetch(PDO::FETCH_ASSOC)){
          $projectName = $u['projectName'];

    ?>
            $("#editModal<?php echo $buildingID ?>").click(function(){
              alert('<?php echo $projectName ?>');
              $("#editBuildingName").val("<?php echo  $r['buildingName'] ?>");
              $("#editBuildingProject").val("<?php   echo $projectName");
              $("#editBuildingFloors").val("<?php  echo $floorNumber ?>");


            });
<?php }}?>
});

最佳答案

代替:


  $("#editBuildingProject").val("<?php echo $projectName");


用这个:


  $("#editBuildingProject").val("<?php echo $building_projectID ?>").material_select('update');

09-07 00:35