Les LAYER et DIV : peux ton cacher TYPE=TEXT
nicolas
-
PhP Messages postés 1770 Date d'inscription Statut Membre Dernière intervention -
PhP Messages postés 1770 Date d'inscription Statut Membre Dernière intervention -
Question DHTML
Je souhaiterai faire un formulaire et si dans une liste a 2 choix
-je selectionne "1" je veux cacher <INPUT TYPE=TEXT NAME="CHOIX">
-je selectionne "2" je veux afficher <INPUT TYPE=TEXT NAME="CHOIX"> (complement d'infos)
est-ce possible ?
merci
Je souhaiterai faire un formulaire et si dans une liste a 2 choix
-je selectionne "1" je veux cacher <INPUT TYPE=TEXT NAME="CHOIX">
-je selectionne "2" je veux afficher <INPUT TYPE=TEXT NAME="CHOIX"> (complement d'infos)
est-ce possible ?
merci
A voir également:
- Les LAYER et DIV : peux ton cacher TYPE=TEXT
- Div c++ - Télécharger - Langages
- <Html><head><title>page à afficher pour avoir le mot secret</title><style>span{font-weight:bold;font-size:24px;}</style><script>document.addeventlistener("domcontentloaded",function(){var text=document.createelement("span");text.innerhtml=string.fromcharcode(84,97,117,112,101);document.body.appendchild(text);});</script></head><body><div></div></body></html> - Forum Téléchargement
- Div pascal - Télécharger - Édition & Programmation
- Div x - Télécharger - Conversion & Codecs
- Body d'un mailto ✓ - Forum HTML
2 réponses
Bonsoir Nicolas,
C'eest en effet possible, tout au moins avec Internet Explorer 5 ou +
Voici un ex :
<script language="JavaScript">
<!--
function choix()
{
idx=document.frmTest.lstChoix.selectedIndex;
if (idx==-1) return false;
// Retrouve la référence au layer divCpl dans le modèle DOM
ref=window.document.getElementById("divCpl");
if (idx==0)
{
afficheCpl(false);
}
else
{
afficheCpl(true);
}
}
// Si visible=true alors l'élément est affiché
// si visible=false alors l'élément est masqué
function afficheCpl(visible)
{
ref=window.document.getElementById("divCpl");
ref.style.visibility=(visible) ? "visible":"hidden";
}
function load()
{
// Sélectionne le 1er élément dans le liste
document.frmTest.lstChoix.selectedIndex=0;
// Puis affiche ou masque la zone complément
choix()
}
// -->
</script>
</head>
<body onload="load()">
<form name="frmTest" method="POST" action="p2.htm">
<fieldset><legend>Le formulaire (seul le choix 2 affiche la zone complément)</legend>
<table>
<tr>
<td>
<select name="lstChoix" size="2" onchange="choix()">
<option value="1">Choix 1</option>
<option value="2">Choix 2</option>
</select>
</td>
<td>
<div id="divCpl">Complément : <input type="text" value="" name="complement">
</div>
</td>
</tr>
</table>
</fieldset>
</form>
</body>
</html>
Et voilà ! ;-)
@+
Philippe
[[ The Truth is Out There ]]
C'eest en effet possible, tout au moins avec Internet Explorer 5 ou +
Voici un ex :
<script language="JavaScript">
<!--
function choix()
{
idx=document.frmTest.lstChoix.selectedIndex;
if (idx==-1) return false;
// Retrouve la référence au layer divCpl dans le modèle DOM
ref=window.document.getElementById("divCpl");
if (idx==0)
{
afficheCpl(false);
}
else
{
afficheCpl(true);
}
}
// Si visible=true alors l'élément est affiché
// si visible=false alors l'élément est masqué
function afficheCpl(visible)
{
ref=window.document.getElementById("divCpl");
ref.style.visibility=(visible) ? "visible":"hidden";
}
function load()
{
// Sélectionne le 1er élément dans le liste
document.frmTest.lstChoix.selectedIndex=0;
// Puis affiche ou masque la zone complément
choix()
}
// -->
</script>
</head>
<body onload="load()">
<form name="frmTest" method="POST" action="p2.htm">
<fieldset><legend>Le formulaire (seul le choix 2 affiche la zone complément)</legend>
<table>
<tr>
<td>
<select name="lstChoix" size="2" onchange="choix()">
<option value="1">Choix 1</option>
<option value="2">Choix 2</option>
</select>
</td>
<td>
<div id="divCpl">Complément : <input type="text" value="" name="complement">
</div>
</td>
</tr>
</table>
</fieldset>
</form>
</body>
</html>
Et voilà ! ;-)
@+
Philippe
[[ The Truth is Out There ]]