[英]Adding a 3rd Option to Questionnaire for “Select an Option”
I have a questionnaire and if the user selects Option 1 or 2 for Select an Option
what they select determines the link that is displayed at the end of the questionnaire. 我有一个调查表,如果用户为“ Select an Option
选择了选项1或2,那么他们选择的内容将确定在调查表末尾显示的链接。 Instead of only 2 options, I would like to have 3 options for Select an Option
. 我希望Select an Option
3个选项,而不仅仅是2 Select an Option
。
Here is the HTML: 这是HTML:
<a id="q1_one" class="step_button next" href="javascript:void(0)">option 1</a>
<a id="q1_two" class="step_button next" href="javascript:void(0)">option 2</a>
This is where I would like to add a q1_three
but I'm not sure how to get it to work 这是我想添加q1_three
但是我不确定如何使它工作
The Javascript: Javascript:
function run_loading_run_4(time_delay, q1) {
timeoutID3 = window.setTimeout(
function() {
run_loading_4(q1);
},
time_delay);
}
function run_loading_4(q1) {
$('.run_loading_4, .loading').hide();
$('.li_run_loading_4, li_run_loading_5, .run_loading_5, .show_end').fadeIn();
$('#' + q1).show();
}
$(function () {
var q1;
$(document).on('click', '.next', function (e) {
e.preventDefault();
$(this).parent().hide().next().fadeIn();
if ($(this).attr('id') === "q1_one") {
q1 = "yes";
} else if ($(this).attr('id') === "q1_two") {
q1 = "no";
}
});
$(document).on('click', '.run_loading', function (e) {
e.preventDefault();
$(this).parent().hide().next().fadeIn();
$('.step4 .loading').show();
run_loading_run_1('2000');
run_loading_run_2('4500');
run_loading_run_3('6500');
run_loading_run_4('8900',q1);
});
});
and the answers: that are displayed depending if option 1 or 2 is selected. 以及答案:根据选择选项1或2而显示。
<div id="yes">
<a class="step_button" href="http://link1.com">I Agree</a>
</div>
<div id="no">
<a class="step_button" href="http://link2.com">I Agree</a>
</div>
JSFIDDLE: http://jsfiddle.net/8r6eH/ JSFIDDLE: http : //jsfiddle.net/8r6eH/
Add option by add following lines: 通过添加以下行来添加选项:
HTML(line#5 and #37); HTML(第5行和第37行);
<h2>Select An Option</h2>
<a id="q1_one" class="step_button next" href="javascript:void(0)">Option 1</a>
<a id="q1_two" class="step_button next" href="javascript:void(0)">Option 2</a>
<a id="q1_three" class="step_button next" href="javascript:void(0)">Option 3</a>
<div id="yes">
<a class="step_button" href="http://link2.com">IF QUESTION 1 = Option 1</a>
</div>
<div id="no">
<a class="step_button" href="http://link1.com">IF QUESTION 1 = Option 2</a>
</div>
<div id="3rd_option">
<a class="step_button" href="http://link1.com">IF QUESTION 1 = Option 3</a>
</div>
and javascript(line#57): 和javascript(第57行):
if ($(this).attr('id') === "q1_one") {
q1 = "yes";
} else if ($(this).attr('id') === "q1_two") {
q1 = "no";
} else if ($(this).attr('id') === "q1_three") {
q1 = "3rd_option";
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.