2012-03-10 64 views
0

好吧,所以我嘗試使用按鈕設置。JQuery單選按鈕組有效和無效

太公平了,我已經能夠將它們轉換爲鏈接。 但是,事情是單選按鈕不保持其活動狀態。

這裏的jQuery代碼:

$("#radio").buttonset(); 

$("input:radio[name=radio]").click(function() { 
var id = $("input[@name=radio]:checked").attr('id'); 
window.location.replace("player.php?id=<?php echo $id; ?>&action="+id); 
} 

這裏是butonset的代碼+後面我的網頁的PHP代碼:

<form> 
<div id="radio" class="ui-buttonset"> 
<input type="radio" id="season" name="radio" value="season" /><label     for="season">Season</label> 
<input type="radio" id="playoff" name="radio" value="playoff" /><label for="playoff">Playoffs</label> 
<input type="radio" id="carrer" name="radio" value="carrer" /><label for="carrer">Carrer</label> 
<input type="radio" id="carrer_playoff" name="radio" id="carrer_playoff"/><label for="carrer_playoff">Carrer playoffs</label> 
</div> 
</form> 
</center> 

<br/><br/> 

<?php 
if($action == "playoff"){ 
include("player_playoff.php"); 
} 
else if($action == "carrer"){ 
include("player_carrer.php"); 
} 
else if($action == "carrer_playoff"){ 
include("player_carrer_playoff.php"); 
} 
else{ 
include("player_season.php"); 
} 

?> 

這是網頁: http://uweave.ca/uw-perso/Aravinthan_Sivaneswaran/COD_Circuit-TW/public%20v2.0/player.php?id=1&action=season

感謝您的幫助, 阿拉

編輯: if($ radio.is(':checked')=== false){ $ radio.filter('[value =]')。attr('checked',true); } if($ radio.filter('[value =]')。attr('checked',true)){ alert(「IN」); }

我這樣做檢查,但它總是提醒我在,但它不把它放在選中(激活)狀態......

+0

單擊該按鈕,當你重新加載頁面。爲什麼按鈕會保持其狀態? – j08691 2012-03-10 18:50:28

+0

Ahhhhh ...當然!!!!!我現在感覺很蠢! – user1049769 2012-03-10 18:55:44

+0

奇怪的用戶界面...爲什麼你會使用無線電進行頁面導航? – charlietfl 2012-03-10 18:56:09

回答

0

閱讀評論你的問題後,這裏是你在找什麼對於

$(function(){ 
    $('input:radio[id="<?php echo $action; ?>"]').attr('checked','checked'); 
}); 

http://jsfiddle.net/seLTY/