Afficher/cacher un Input au changement d'un Select
Bonjour à tous.
Alors voilà mon problème :
J'ai un select que je j'utilise pour cacher ou non un input avec du JS. Les valeurs "une société" et "une association" affiche mon input alors que "un utilisateur" va le masquer.
J'arrive bien à récupérer la valeur de mon select. Après la vérification la fonction JS ne marche plus...
Voilà le code :
Code:
1 2 3 4 5 6
| <select name="typ" id='one' onchange="affiche(this.selectedIndex)">
<option value="0" <?php if (isset($_POST['typ']) and $_POST['typ'] == '0') {echo "selected='selected'";}?>>societe</option>
<option value="1" <?php if (isset($_POST['typ']) and $_POST['typ'] == '1') {echo "selected='selected'";}?>>asso</option>
<option value="2" <?php if (isset($_POST['typ']) and $_POST['typ'] == '2') {echo "selected='selected'";}?>>particulier</option>
</select>
<div id="supp"><label><?php echo nomsupp; ?> |
Le JS si besoin est :
Code:
1 2 3 4 5 6 7 8 9 10
| function affiche(choix){
switch (choix){
case 0 : document.getElementById('supp').style.visibility='visible'
break;
case 1 : document.getElementById('supp').style.visibility='visible'
break;
case 2 : document.getElementById('supp').style.visibility='hidden'
break;
}
} |
Pourquoi le PHP désactive-t-il le JS ? Merci d'avance !