提问人:Bart Roels 提问时间:3/19/2023 更新时间:3/19/2023 访问量:42
如何限制表单字段中的输入选项,在其他字段中值的函数中(php mySQL)
how to restrict input options in form field, in function of value in other field (php mySQL)
问:
我有一个简单的html表单。您可以在字段 1 中选择国家/地区,在字段 2 中选择城市。但是,字段 2 中的城市只能是该国的城市...... 因此,一旦第一个字段具有值,例如比利时,就必须限制城市列表。国家和城市都在数据库中,这没问题。但是,如何在不提交表单的情况下引用第一个字段的内容?
<form action="/index.php" method="post">
<select id="country" name="country">
<option>Country</option>
<option value="Belgium">Belgium</option>
<option value="Germany">Germany</option>
<option value="The Netherlands">The Netherlands</option>
</select>
<br>
<select id="city" name="city">
<option>City</option>
<option value="Cologne">Cologne</option>
<option value="Berlin">Berlin</option>
<option value="Amsterdam">Amsterdam</option>
<option value="Antwerp">Antwerp</option>
<option value="Brussels">Brussels</option>
<option value="Rotterdam">Rotterdam</option>
<option value="Breda">Breda</option>
<option value="Utrecht">Utrecht</option>
</select>
<input style="margin-bottom: 15px;" type="submit" value="Search!">
</form>
我尝试了 $_GET['country'],但它总是返回 NULL......
答: 暂无答案
评论
<select>
<select>