簡體   English   中英

在調查表中添加“選擇選項”的第三個選項

[英]Adding a 3rd Option to Questionnaire for “Select an Option”

我有一個調查表,如果用戶為“ Select an Option選擇了選項1或2,那么他們選擇的內容將確定在調查表末尾顯示的鏈接。 我希望Select an Option 3個選項,而不僅僅是2 Select an Option

這是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>

這是我想添加q1_three但是我不確定如何使它工作

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);

    });
});

以及答案:根據選擇選項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/

通過添加以下行來添加選項:
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>

和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";
}

jsFiddle

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM