要求不适用于html中的链式下拉php mysql

时间:2019-03-21 21:51:07

标签: javascript php html

第一个下拉必填字段仅未生效。在第一个下拉字段之后,其余的字段将生效。首先下拉菜单不起作用。我正在使用javascript从MySQL填充下拉列表值,请找到错误

<div class="form-group col-md-8">
      <label></label>
      <form name="service" action="bookdat.php" method="get">
       <select id="father" name="father" class="form-control"  required="required">
       <option> Choose...</option>
       <?php
//Include database configuration file
include('dat/conn.php');

//Get all country data
$query = $db->query("SELECT * FROM father ORDER BY father ASC");

//Count total number of rows
$rowCount = $query->num_rows;
?>

      <?php
    if($rowCount > 0){
        while($row = $query->fetch_assoc()){ 
            echo '<option value="'.$row['father_id'].'" >'.$row['father'].'  </option>';
        }
    }else{
        echo '<option value="">father not available</option>';
    }
    ?>
      </select>
    </div> <!-- form-group end.// -->
    <div class="form-group col-md-8">
      <label></label>
      <select id="child" name="child" class="form-control"     required="required">
        <option> Choose...</option>

      </select>
    </div> <!-- form-group end.// -->
    <div class="form-group col-md-8">
      <label></label>
      <select id="school" class="form-control" name="school"  required="required">
        <option> Choose...</option>

      </select>
    </div> <!-- form-group end.// -->

     <div class="form-group col-md-8">
      <label></label>
      <select id="grade" class="form-control" name="grade"  required="required" >
        <option> Choose...</option>

      </select>
    </div> <!-- form-group end.// -->

</div> <!-- form-row.// -->

<div class="form-group">
    <button type="submit" class="btn btn-primary btn-block"> book service </button>
</div> <!-- form-group// -->      

1 个答案:

答案 0 :(得分:0)

我发现了错误。

 <option> Choose...</option> i changed this to   <option value="">Choose...</option>

现在需要验证器工作