gpt4 book ai didi

php - 当用户选择其他选项时添加另一个文本框

转载 作者:行者123 更新时间:2023-11-30 01:33:32 25 4
gpt4 key购买 nike

我的表单如下所示。

<form action="add_customers.php" method="post"     onsubmit="MM_validateForm('name','','R','passport_no','','R','remarks','','R');return     document.MM_returnValue">
<tr>
<td>Name of the Applicant:</td>
<td><label for="name"></label>
<input type="text" name="name" id="name" /></td>
</tr>
<tr>
<td>Country applying for :</td>
<td><label for="country"></label>
<select name="country" id="country">
<option>Singapore</option>
<option>Malaysia</option>
<option>Istanbul</option>
<option>Thailand</option>
<option>China</option>
<option>Other</option>
</select></td>
</tr>
<tr>
<td>Visa Categeory :</td>
<td><label for="visa_categeory"></label>
<select name="visa_categeory" id="visa_categeory">
<option>Visit</option>
<option>Business</option>
<option>Other</option>
</select></td>
</tr>
<tr>
<td>Passport No:</td>
<td><input type="text" name="passport_no" id="passport_no" /></td>
</tr>
<tr>
<td>Remarks:</td>
<td><label for="remarks"></label>
<textarea name="remarks" id="remarks" cols="45" rows="5"></textarea></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type="submit" name="submit" id="submit" value="Submit" /></td>
</tr></form>

现在我的问题是1)当用户从签证类别中选择其他选项时,会自动为用户显示一个文本框并捕获他输入的内容。2) 将详细信息保存到 mysql 数据库

使用的语言有PHP、MYSQL

谢谢。

最佳答案

您可以在表单中添加文本框并在第一次时将其隐藏。
使用 JavaScript 更改您提到的下拉列表时使文本框可见。
您可以获取接受数据的页面中文本框的值,并将其与其他变量一起插入到 add_customers.php 中的数据数据库中。

<script>
function visacatOnchange(){
var visa_cat = document.getElementById('visa_categeory').value
if(visa_cat == "Visit")
document.getElementById("new_textbox").style.display="block";
else
document.getElementById("new_textbox").style.display="none";
}
</script>

以html形式添加

<input type="text" name="new_textbox" id="new_textbox" style="display:none;">

并改变

<select name="visa_categeory" id="visa_categeory" onChange="visacatOnchange();">

祝你好运:-)

关于php - 当用户选择其他选项时添加另一个文本框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17183023/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com