Bonjour a tous,je suis débutant en javascript,il y a un petit problème dans mon script,ca me bloque qqs heures,je m'en sors pas.
Voici la demande :
"Si le bouton radio Société est sélectionné, la zone « Prénom » est rendue inactive et grisée
(Utilisez style.backgroundColor). Si un prénom est déjà indiqué, on vide cette zone."
Le contenu de inscription.html :
Code html : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Inscription</title> <script type="text/javascript" src="inscription.js"></script> </head> <body> <table> <form name="formulaire" method="get"> <tr> <td>Nom</td> <td><input type="text" name="nom"></td> </tr> <tr> <td>Prénom</td> <td><input type="text" name="prenom"></td> </tr> <tr> <td><input type="radio" name="radio" value="Particulier">Particulier</td> <td><input type="radio" name="radio" value="Société">Société</td> </tr> <tr colspan ="2" text-align="center"> <td "><input type="submit" ></td> </tr> </form> </table> </body> </html>
Le contenu de inscription.js :
Voici mes question :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10 function soumettre() { document.forms[0].prenom = ""; document.forms[0].prenom.style.backgroundColor="gray"; } window.onload = function() { document.forms[0].onsubmit = soumettre; }
1.Quelle est la difference entre "document.forms[0].onsubmit = soumettre;" et "document.forms[0].onsubmit = soumettre();"
2.J'ai vu dans mon page HTML,le champ prenom est grisé pendant un millisecond,et après il redevient blanc.pq?
Partager