試圖讓單選按鈕切換,發佈執行相應PHP代碼的表單並更改活動類。無論我嘗試了什麼,我都無法讓它工作。這裏的HTML:單選按鈕jQuery切換問題
<form id="activeform" action="inc/togglevalid.php" method="post">
<input type="hidden" name="id" value="<? echo $events["id"];?>" />
<span class="btn-group" data-toggle="buttons">
<label class="btn btn-xs btn-default <? if ($events['valid']=='yes') echo "active";?>"><input class="radiobtn" type="radio" name="valid" id="yes" value="yes"><?=ucwords($phrase['yes']);?></label>
<label class="btn btn-xs btn-default <? if ($events['valid']=='no') echo "active";?>"><input class="radiobtn" type="radio" name="valid" id="no" value="no"><?=ucwords($phrase['no']);?></label>
</span>
</form>
,這裏是jQuery代碼嘗試各種變化後SOFAR:
$('#activeform .btn').on('click',(function()) {
$.post($(this).parents('form').attr('action'),formInput, function(data){
$(this).sibling.removeClass('active');
$(this).addClass('active');
});
return false;
});
它只是將無法工作,另一個腳本停止工作,一旦我添加此代碼。任何幫助將不勝感激。
親切問候 約翰
如果後續腳本失敗在控制檯中看到任何內容都必須有錯誤? – happymacarts
http://stackoverflow.com/questions/2097816/how-to-post-radio-button-values-through-jquery –