在我的 html 表单中,我有两组单选按钮,根据它的响应,我正在显示一个隐藏的div
我的 HTML 代码:
<div class="input-quest">Question 1</div>
<div class="input-resp">
<input onClick="question_1_response_yes();" type="radio" name="button1" value="Yes" checked /><label>Yes</label>
<input onClick="question_1_response_no();" type="radio" name="button1" value="No" /><label>No</label>
</div>
<div class="input-quest">Question 2</div>
<div class="input-resp">
<input onClick="question_2_response_yes();" type="radio" name="button2" value="Yes" checked /><label>Yes</label>
<input onClick="question_2_response_no();" type="radio" name="button2" value="No" /><label>No</label>
</div>
<div id="response-q1-yes-q2-yes" style="display:none;">
<div class="block">
<div class="input-quest">Question 3</div>
<div class="input-resp"><span><input class="textbox" id="q3" name="q3" type="text" value=" " /></span></div>
</div>
</div>
<div id="response-q1-yes-q2-no" style="display:none;">
<div class="block">
<div class="input-quest">Question 4</div>
<div class="input-resp"><span><input class="textbox" id="q4" name="q4" type="text" value=" " /></span></div>
</div>
</div>
<div id="response-q1-no-q2-yes" style="display:none;">
<div class="block">
<div class="input-quest">Question 5</div>
<div class="input-resp"><span><input class="textbox" id="q5" name="q5" type="text" value=" " /></span></div>
</div>
</div>
<div id="response-q1-no-q2-no" style="display:none;">
<div class="block">
<div class="input-quest">Question 6</div>
<div class="input-resp"><span><input class="textbox" id="q6" name="q6" type="text" value=" " /></span></div>
</div>
</div>
我能够显示隐藏的 div 取决于使用 onclick 功能的单个单选按钮,例如
function question_1_response_yes() {
$('#response-q1-yes-q2-yes').slideDown("fast");
$('#response-q1-yes-q2-no').slideUp("fast");
$('#response-q2-no-q2-yes').slideUp("fast");
$('#response-q1-no-q2-no').slideUp("fast");
}
但我需要显示隐藏的文本框取决于两组单选按钮选择,例如
question-1 yes and question-2 yes ---> display div `response-q1-yes-q2-yes`
question-1 yes and question-2 no ---> display div `response-q1-yes-q2-no`
question-1 no and question-2 yes ---> display div `response-q1-no-q2-yes`
question-1 no and question-2 no ---> display div `response-q1-no-q2-no`
我必须在两个单选按钮选择之后才显示隐藏的 div。怎么能做到这一点