нещо сложно което ме мъчи с дни наред jQuery

kWo_2

Registered
1. примерно имам 5 checkbox полета и ако кликна на едното то на другите 4 да не мога да кликна.
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251" />
<title>Untitled Document</title>
<style type="text/css">
#main { width:600px; height:100px; background:yellow; }
.acordion { width:30px; height:100px; border:solid 1px red; float:left; }
</style>
<script type="text/javascript" src="jquery-1.3.2.js"></script>
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery("body input[type='checkbox']").click(function(){
jQuery("body input[type='checkbox']").each(function(){
jQuery(this).attr({"disabled":"disabled"});
})
jQuery(this).attr({"disabled":""});
})
})
</script>
</head>

<body>
<input name="" type="checkbox" value="" />
<input name="" type="checkbox" value="" />
<input name="" type="checkbox" value="" />
<input name="" type="checkbox" value="" />
<input name="" type="checkbox" value="" />
</body>
</html>
 
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
var matches = 0;
$(document).ready(function() {
$("input[type=checkbox]").click(function() {
$("input[type=checkbox]").each(function() {
if (!this.checked) { this.disabled = "disabled";matches++; }
});
if (matches>4) { $("input[type=checkbox]").each(function() { this.disabled = false; }); }
matches = 0;
});
});
</script>
<input type="checkbox" />
<input type="checkbox" />
<input type="checkbox" />
<input type="checkbox" />
<input type="checkbox" />
 
Я кажи каква ти е логиката да са чекбоксове? Точно това което се мъчиш трябва да е радиобутини, ако гледаме логически на нещата.
 
Благодаря на емаги и мариан :) ще и полвам кода на мариан че е деселектват след втори клик


shterev защото за целта ми трябват checkbox :)
 

Back
Горе