不确定为什么但是我做的循环输出每个选择但第一个正确输出。看起来循环在第一次围绕节目的早期结束。 loop ending early循环从第一个选择1获取其信息:。然后做一个ajax调用2:php页面,它将$ days设置为第一个选择选项值。然后循环输出两个选择,直到它等于$ days。 The output showing the other selects working
1:首先选择
<form>
<div class="form-group">
<label for="exampleFormControlSelect1">How many days?</label>
<select class="form-control" name="days" onchange="Selectdays(this.value);" id="exampleFormControlSelect1" required>
<option>How many days?</option>
<option value="1">1 day</option>
<option value="2">2 days</option>
<option value="3">3 days</option>
<option value="4">4 days</option>
<option value="5">5 days</option>
<option value="6">6 days</option>
<option value="7">7 days</option>
<option value="8">8 days</option>
<option value="9">9 days</option>
<option value="10">10 days</option>
</select>
</div>
<div id="days"></div>
2:秒选择循环内部
$count = 0;
echo "<select class='form-control' name='select' id='exampleFormControlSelect1'> ";
while($count != $days) {
echo "
<div class='form-group'>
<label for='exampleFormControlSelect1'>Date</label>
<select class='form-control' name='date' id='exampleFormControlSelect1'>
<option>05/24/2018</option>
<option>06/2/2018</option>
<option>07/25/2019</option>
<option>01/15/2017</option>
<option>11/5/2018</option>
</select>
</div>
<br>
<div class='form-group'>
<label for='exampleFormControlSelect1'>Hours</label>
<select class='form-control' name='time' id='exampleFormControlSelect1' required>
<option value=''>How many hours?</option>
<option>1 hour</option>
<option>2 hours</option>
<option>3 hours</option>
<option>4 hours</option>
<option>5 hours</option>
<option>6 hours</option>
<option>7 hours</option>
<option>8 hours</option>
</select>
</div>";
$count++;
}