チェックボックスリストがあります。これには3つのアイテムがあります
- 男性 2.女性 3.不明
誰かが不明を選択した場合、チェックボックスリストの他の選択を無効にする必要があります。[不明] が選択されている場合は、何も選択できません。j クエリ、Java スクリプト、C# コードはすべて役に立ちます...
チェックボックスリストがあります。これには3つのアイテムがあります
誰かが不明を選択した場合、チェックボックスリストの他の選択を無効にする必要があります。[不明] が選択されている場合は、何も選択できません。j クエリ、Java スクリプト、C# コードはすべて役に立ちます...
次のようなことを試すことができます:-
$('.optionBox input:checkbox').click(function(){
var $x= $('.optionBox input:checkbox');
if($(this).is(':checked')){
$x.not(this).prop('disabled',true);
}
else
{
.....
}
})
これを処理するには、jquery で以下のコードを使用できます。
$(document).ready(function(){
$("#unknown").change(function(){
if($(this).is(":checked"))
$("#male, #female").attr('disabled','disabled');
else
$("#male, #female").removeAttr('disabled','disabled');
});
});
ここで、これを試してください: http://jsfiddle.net/m8Leu/
// store the inputs and bind the change event
var $inputs = $( ".chkGroup input" );
$inputs.on( "change" , function(e) {
// store the item that changed and the ones that didnt.
var $changed = $(e.target);
var $others = $inputs.not( $changed );
// if the item that changed is "unknown"
if( $changed.hasClass( "unique" ) ) {
// save the state of the "unknown" chk
// and set the other chks to it's state
var state = $changed.prop( "checked" )
$others.prop( "disabled", state );
// for good measure, we'll uncheck the
// others because they are disabled
if( state ) {
$others.prop( "checked" , false );
}
}
});