我正在一个项目中,用户可以方便地输入他的记录,我想知道如何在更改选择框值的同时显示或隐藏文本框
在这里,我有一个以婚姻状况命名的选择框
婚姻状况的选项有:“已婚”和“未婚”。
这是代码:
<select class="form-control" name="Personal_Family_Marital_Status" id="Personal_Family_Marital_Status" style = "color: black;" required>
<option value="">Please Select Marital Status</option>
<option value="Married">Married</option>
<option value="Un-Married">Un-Married</option>
</select>
<div class = "form-group col-md-3">
<label for = "cc-payment" class = "control-label mb-1">Spouse Name</label>
<input type = "text" autocomplete="off" class = "form-control" name="Persoanl_Family_Spouse_Name" id = "Persoanl_Family_Spouse_Name" style = "color: black;" value="" placeholder="Mention your Spouse Name" data-toggle="tooltip" title="Mention your Spouse Name if Applicable" required />
</div>
如果用户从上述选项中选择“已婚”,则会出现一个文本框,用于输入配偶姓名
如果用户从上述选项中选择“未婚”,则配偶姓名文本框应消失。