Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

i have this form that starts with 1 select DISABLED and 4 options i need a jquery that does this:

if OPTION #1 (on click) check if other options are selected and RESET (erase values and uncheck boxes)

if OPTION #2 (on click) ACTIVATE select menu and check if other options are selected and RESET (erase values and uncheck boxes)

if OPTION #3 (on click) check if other options are selected and RESET (erase values and uncheck boxes)

if OPTION #4 (on keyup) ACTIVATE select menu RESET and DISABLE other options

<!DOCTYPE html>
<html>
<script type="text/javascript">
    $(document).ready(function()
        {   

        }); 
</script>               
<body>
<select name="menus" id="menus" style="width:500px; height:200px" size="3"  disabled="disabled">
<option value="">Test#1</option>
<option value="">Test#2</option>
</select>
<div>
Option #1 <input name="op1" type="checkbox" value="">
</div>
<div>
Option #2 <input name="op2" type="checkbox" value="">
</div>
<div>
Option #3 <input name="op3" type="checkbox" value="">
</div>
<div>
Option #4 <input name="" type="text">
</div>
</body>
</html>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
205 views
Welcome To Ask or Share your Answers For Others

1 Answer

Updated fiddle: http://jsfiddle.net/zZSJb/3/


Something like this: http://jsfiddle.net/zZSJb/

$('#op1, #op3').click(function() {
    $('input[type="checkbox"]').removeAttr('checked');
    $(this).attr('checked', true);
});

$('#op2').click(function() {
    $('#menus').removeAttr('disabled');
    $('input[type="checkbox"]').removeAttr('checked');    
    $(this).attr('checked', true);
});

$('#txt').keyup(function() {
    $('#menus').removeAttr('disabled');
    $('input[type="checkbox"]').removeAttr('checked').attr('disabled', true);
});

You may need to fine tune it to your exact needs (which I couldn't completely figure out!).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...