par
jeff34 » 13 mai 2005, 17:03
Voilà qui devrait marcher pour ta vérification :
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<style type="text/css"><!--
div {
margin: 1px;
height: 440px;
padding: 1px;
border: 1px solid #000;
width: 250px;
background: pink;
color: #ffffff;
top: 38px;
}
-->
</style>
<title>Untitled</title>
<script type="text/javascript">
function verif(min,maform)
//maform= l'id de la forme qui va bien
//min = le nombre min de checkbox cochés
{
j=0;
for (i=0; i<maform.length; i++)
{
meschecks = maform.elements[i];
if (meschecks.checked)
{
j++;
}
}
if (j<min)
{
alert('Vous n\'avez pas coché suffisament de cases');
}
else
{
maform.submit();
}
}
</script>
</head>
<body>
<form action="3.php" method="post" name="form" >
<div><b><br>
1 <input type="checkbox" name='choix[1]'' value='1'/>
2 <input type="checkbox" name='choix[2]' value='2'/>
3 <input type="checkbox" name='choix[3]' value='3'/>
4 <input type="checkbox" name='choix[4]' value='4'/>
5 <input type="checkbox" name='choix[5]' value='5'/>
6 <input type="checkbox" name='choix[6]' value='6'/>
<br><hr><br>
7 <input type="checkbox" name='choix[7]' value='7'/>
8 <input type="checkbox" name='choix[8]' value='8'/>
9 <input type="checkbox" name='choix[9]' value='9'/>
10<input type="checkbox" name='choix[10]' value='10'/>
11<input type="checkbox" name='choix[11]' value='11'/>
12<input type="checkbox" name='choix[12]' value='12'/>
<br><hr><br>
13<input type="checkbox" name='choix[13]' value='13'/>
14<input type="checkbox" name='choix[14]' value='14'/>
15<input type="checkbox" name='choix[15]' value='15'/>
16<input type="checkbox" name='choix[16]' value='16'/>
17<input type="checkbox" name='choix[17]' value='17'/>
18<input type="checkbox" name='choix[18]' value='18'/>
<br><hr><br>
19<input type="checkbox" name='choix[19]' value='19'/>
20<input type="checkbox" name='choix[20]' value='20'/>
21<input type="checkbox" name='choix[21]' value='21'/>
22<input type="checkbox" name='choix[22]' value='22'/>
23<input type="checkbox" name='choix[23]' value='23'/>
24<input type="checkbox" name='choix[24]' value='24'/>
<br><hr><br>
25<input type="checkbox" name='choix[25]' value='25'/>
26<input type="checkbox" name='choix[26]' value='26'/>
27<input type="checkbox" name='choix[27]' value='27'/>
28<input type="checkbox" name='choix[28]' value='28'/>
29<input type="checkbox" name='choix[29]' value='29'/>
30<input type="checkbox" name='choix[30]' value='30'/>
<br><hr><br>
31<input type="checkbox" name='choix[31]' value='31'/>
32<input type="checkbox" name='choix[32]' value='32'/>
33<input type="checkbox" name='choix[33]' value='33'/>
34<input type="checkbox" name='choix[34]' value='34'/>
35<input type="checkbox" name='choix[35]' value='35'/>
36<input type="checkbox" name='choix[36]' value='36'/>
<br><hr><br>
37<input type="checkbox" name='choix[37]' value='37'/>
38<input type="checkbox" name='choix[38]' value='38'/>
39<input type="checkbox" name='choix[39]' value='39'/>
40<input type="checkbox" name='choix[40]' value='40'/>
41<input type="checkbox" name='choix[41]' value='41'/>
42<input type="checkbox" name='choix[42]' value='42'/>
<br><hr></b>
<center><input type="reset"/>
<input type="submit" value="Ok" onclick="verif(6,document.form);return false;" /></center>
</div
</form>
</body>
</html>
@++
Voilà qui devrait marcher pour ta vérification :
[php]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<style type="text/css"><!--
div {
margin: 1px;
height: 440px;
padding: 1px;
border: 1px solid #000;
width: 250px;
background: pink;
color: #ffffff;
top: 38px;
}
-->
</style>
<title>Untitled</title>
<script type="text/javascript">
function verif(min,maform)
//maform= l'id de la forme qui va bien
//min = le nombre min de checkbox cochés
{
j=0;
for (i=0; i<maform.length; i++)
{
meschecks = maform.elements[i];
if (meschecks.checked)
{
j++;
}
}
if (j<min)
{
alert('Vous n\'avez pas coché suffisament de cases');
}
else
{
maform.submit();
}
}
</script>
</head>
<body>
<form action="3.php" method="post" name="form" >
<div><b><br>
1 <input type="checkbox" name='choix[1]'' value='1'/>
2 <input type="checkbox" name='choix[2]' value='2'/>
3 <input type="checkbox" name='choix[3]' value='3'/>
4 <input type="checkbox" name='choix[4]' value='4'/>
5 <input type="checkbox" name='choix[5]' value='5'/>
6 <input type="checkbox" name='choix[6]' value='6'/>
<br><hr><br>
7 <input type="checkbox" name='choix[7]' value='7'/>
8 <input type="checkbox" name='choix[8]' value='8'/>
9 <input type="checkbox" name='choix[9]' value='9'/>
10<input type="checkbox" name='choix[10]' value='10'/>
11<input type="checkbox" name='choix[11]' value='11'/>
12<input type="checkbox" name='choix[12]' value='12'/>
<br><hr><br>
13<input type="checkbox" name='choix[13]' value='13'/>
14<input type="checkbox" name='choix[14]' value='14'/>
15<input type="checkbox" name='choix[15]' value='15'/>
16<input type="checkbox" name='choix[16]' value='16'/>
17<input type="checkbox" name='choix[17]' value='17'/>
18<input type="checkbox" name='choix[18]' value='18'/>
<br><hr><br>
19<input type="checkbox" name='choix[19]' value='19'/>
20<input type="checkbox" name='choix[20]' value='20'/>
21<input type="checkbox" name='choix[21]' value='21'/>
22<input type="checkbox" name='choix[22]' value='22'/>
23<input type="checkbox" name='choix[23]' value='23'/>
24<input type="checkbox" name='choix[24]' value='24'/>
<br><hr><br>
25<input type="checkbox" name='choix[25]' value='25'/>
26<input type="checkbox" name='choix[26]' value='26'/>
27<input type="checkbox" name='choix[27]' value='27'/>
28<input type="checkbox" name='choix[28]' value='28'/>
29<input type="checkbox" name='choix[29]' value='29'/>
30<input type="checkbox" name='choix[30]' value='30'/>
<br><hr><br>
31<input type="checkbox" name='choix[31]' value='31'/>
32<input type="checkbox" name='choix[32]' value='32'/>
33<input type="checkbox" name='choix[33]' value='33'/>
34<input type="checkbox" name='choix[34]' value='34'/>
35<input type="checkbox" name='choix[35]' value='35'/>
36<input type="checkbox" name='choix[36]' value='36'/>
<br><hr><br>
37<input type="checkbox" name='choix[37]' value='37'/>
38<input type="checkbox" name='choix[38]' value='38'/>
39<input type="checkbox" name='choix[39]' value='39'/>
40<input type="checkbox" name='choix[40]' value='40'/>
41<input type="checkbox" name='choix[41]' value='41'/>
42<input type="checkbox" name='choix[42]' value='42'/>
<br><hr></b>
<center><input type="reset"/>
<input type="submit" value="Ok" onclick="verif(6,document.form);return false;" /></center>
</div
</form>
</body>
</html> [/php]
@++