我正在尝试根据另一种形式的选择显示隐藏的表单部分。每当用户在表单中选择一个选项时,它应该显示另一个表单。如果将鼠标移到单个未隐藏的表单上,则以下代码以这种方式工作:
$('id_35').hover(function(){
$('id_33').show();
});
但是当我在表格35中选择了一个实际选项时,我试图显示“id_33”。这是表格35的HTML,在JSP页面中:
<li class="form-line" id="id_35">
<label class="form-label-left" id="label_35" for="input_35">
Available Start Dates<span class="form-required">*</span>
</label>
<div id="cid_35" class="form-input"><span class="form-sub-label-container">
<select class="form- dropdown validate[required]" style="width:500px" id="input_35" name="q35_availableStart"> <option value="">Please Select</option>
<%
int evar = 0;
String[] xvar = rslt2.split(";")
while (evar < StartDates.length) {
xvar = StartDates[evar].split(";");
out.println("<option value=\""+xvar[0]+"\">"+xvar[0]+"</option>");
evar++;
}
out.println("</select>");
%>
<label class="form-sub-label" for="input_35"> Choose from the Available Start Dates </label></span>`enter code here`
</div>
</li>
答案 0 :(得分:1)
试试这个
$('#id_35').hover(function(){
$('#id_33').show();
});
答案 1 :(得分:0)
您可以为select
$("#input_35").change(function() {
//If you want to show the form when a specific value has been selected
var selectedValue = this.value;
if (selectedValue == "condition_here") {
$("#id_33").show();
}
});
答案 2 :(得分:0)
试试这个:
(首先使用复选框进行编辑,现在接受checkbox
或option
$(document).on("change", ".show", function (event) {
if (this.checked == true || this.value == "show") // Checkbox or Option
$("#f2").show();
else
$("#f2").hide();
});