0

アンケートがあり、ユーザーがオプション 1 または 2 をSelect an Option選択すると、アンケートの最後に表示されるリンクが決まります。のオプションを 2 つだけではなく、3 つにしたいと考えています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/

4

1 に答える 1

0

次の行を追加してオプションを追加します:
HTML(line#5 and #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";
}

jsフィドル

于 2013-10-05T05:25:55.390 に答える