我正在嘗試爲用戶創建一個開放環境來選擇特定的選項,但同時給他們提供了以任何順序選擇它們的機會,但是卻沒有選擇他們選擇了。到目前爲止,我的代碼在按順序執行時停止了我的工作。基本上,選擇和選項在一個範圍內彈出。他們選擇一個。結果會在該範圍內傳遞,同樣的選項似乎還沒有消除他們已經選擇的選項。根據用戶的決定禁用選定的選項
這裏的HTML代碼
<div><select id="lies">
<option value="" selected='selected'>Select a lie...</option>
<option value="FBI">We're undercover agents</option>
<option value="super">We're superheroes</option>
<option value="confess">We're the bombers</option>
</select></div>
<span id='FBI'>
<p>"We're undercover students working with the FBI," you say.</p>
<p>"Get outta here before I put you both in cuffs!" he yells.</p>
<p>"Good job, <?php echo $_GET['Name']?>! You almost got us busted.." </p>
<p>"Come on, Korra, let's try one more! Over there!" you exclaim.</p>
<div><select id="lies">
<option value="" selected='selected'>Select a lie...</option>
<option value="FBI">We're undercover agents</option>
<option value="super">We're superheroes</option>
<option value="confess">We're the bombers</option>
</select></div>
</span>
<span id='super'>
<p>"Let us through, we're bulletproof!" you fearlessly say.</p>
<p>"Are ya now?" asks the cop as he lightly bops you over the head with his fist.</p>
<p>"OW!" you yell.</p>
<p>"Run along and go play somewhere else, stupid kid!"</p>
<p>You and Korra walk away feeling defeated.</p>
<p>"Any other ideas, <?php echo $_GET['Name']?>?" she asks.</p>
<p>"One more try!" you say as you run over to another police officer.</p>
<div><select id="lies">
<option value="" selected='selected'>Select a lie...</option>
<option value="FBI">We're undercover agents</option>
<option value="super">We're superheroes</option>
<option value="confess">We're the bombers</option>
</select></div>
</span>
<span id='confess'>
<p>"It was us!"</p>
<p>"Alright off to jail you go!" says the officer.</p>
You get escorted off to jail. THE END.
</span>
,這裏是jQuery的
//Keeps the spans containing the respondes hidden until an option is selected for the lietocops page
$('#lies').change(function(){
var contact = $(this).val();
// Hides the list/show list
if (contact == ""){
$('#lies').show();
}else{
$('#lies').hide();
}
$("#lies option:selected").attr('disabled','disabled')
.siblings().removeAttr('disabled');
// lie responses
if(contact == "FBI") {
$('#FBI').fadeIn();
}else if(contact == "super") {
$('#super').fadeIn();
}else if(contact == "confess") {
$('#confess').fadeIn();
}
});
我不知道看什麼你想在這裏做,你可以重新制定該好嗎? – sebastienbarbier
用戶可以從列表中選擇一個選項。 選項a,b或c。 用戶選擇一個選項。故事通過執行特定的跨度繼續執行所選擇的選項,並給予另一組選項,同時消除已選擇的選項。我希望能夠以任何順序執行代碼。 –
即時通訊工作在互動小說 –