Javascript bouton radio
Résolu
kyride
-
swoog42 Messages postés 1060 Date d'inscription Statut Membre Dernière intervention -
swoog42 Messages postés 1060 Date d'inscription Statut Membre Dernière intervention -
Bonjour,
je dois selon la page cocher une case differente
Par exemple "page libraire" je coche la case librairies donc voici mon code
je dois selon la page cocher une case differente
Par exemple "page libraire" je coche la case librairies donc voici mon code
<form method = "post" action = "adherent.php" > <div style="top:25px;"> <input type = "image" src = "Images/map-fr.png" alt = "submit button" tabindex = "90" id = "image_form" /> <ul id = "list_metier"> <li> <input type = "radio" name = "metier" value = "lib" id = "lib" tabindex = "10" /> <label for = "lib">Librairie - Papeterie</label> </li> <li> <input type = "radio" name = "metier" id = "entreprise" value = "entreprise" tabindex = "20" /> <label for = "entreprise">Entreprise</label> </li> <li> <input type = "radio" name = "metier" id = "education" value = "education" tabindex = "30" /> <label for = "education">Education</label> </li> <li> <input type = "radio" name = "metier" id = "enfance" value = "enfance" tabindex = "40" /> <label for = "enfance">Petite Enfance</label> </li> <li> <label for = "select_dep">Dep</label> <select name = "select_dep" id = "select_dep" tabindex = "50"> <?php $i = 1; while ($i <= 95) { if ($i == 1) echo "<option value = \"".$i."\" selected = \"selected\">"."0".$i."</option>"; else { if (strlen($i) == 1) echo "<option value = \"".$i."\">"."0".$i."</option>"; else echo "<option value = \"".$i."\">".$i."</option>"; } $i++; } ?> </select> </li> </ul> <div id = "button_form"> <a href = "adherent.php" onclick = "change_url(this, 'dom');" onmouseup = "change_img_on_click('Images/b-dom-on.png', 'dom_button');" onmousedown = "change_img_on_click('Images/b-dom-off.png', 'dom_button');"><img src = "Images/b-dom-on.png" alt = "boutton_dom" id = "dom_button"/></a><a href = "adherent.php" onclick = "change_url(this, 'tom');" onmouseup = "change_img_on_click('Images/b-tom-on.png', 'tom_button');" onmousedown = "change_img_on_click('Images/b-tom-off.png', 'tom_button');"><img src = "Images/b-tom-on.png" alt = "boutton_tom" id = "tom_button" /></a><a href = "adherent.php" onclick = "change_url(this, 'oth');" onmouseup = "change_img_on_click('Images/b-pays-on.png', 'other_count_button');" onmousedown = "change_img_on_click('Images/b-pays-off.png', 'other_count_button');"><img src = "Images/b-pays-on.png" alt = "autre pays" id = "other_count_button"/></a> </div> </div> </form> </div> <!-- distrib --> </div> <!-- top header --> </div> <!-- header_site --> <!--le test pour cocher les cases--> <?php switch ($_SERVER["PHP_SELF"]) <!-- donc la je recuperer par exemple /libraire.php--> { case "/librairie.php"; ?><script>alert('<?=$_SERVER["PHP_SELF"]?>');document.form[0].list_metier.metier.checked=true;</script><?php break; } ?> Donc via le switch je voudrai cocher une case differentes selon l'url mais rien ne fonctionne Auriez vous une astuce? ( je suis censé respecter les normes w3c au passage) Cdt
A voir également:
- Javascript bouton radio
- Radio française - Télécharger - Médias et Actualité
- Bouton reinitialisation pc - Guide
- Diagnostic bouton photo - Accueil - Outils
- Bouton on/off comment savoir ✓ - Forum Matériel & Système
- Symbole arrêt marche - Forum Word
4 réponses
remplace les "name" par "id" et dans ton code, change
par
Pour voir ce que ca donne.
document.recherche.metier[0].checked=true;
par
document.getElementById("metier").checked=true;"
Pour voir ce que ca donne.
super ca marche mais c'est pas
document.getElementById("metier").checked=true;
Mais
document.getElementById("lib").checked=true;
--> metier c'est le "name" =)
Merci swoog =)
u're my bill gates
document.getElementById("metier").checked=true;
Mais
document.getElementById("lib").checked=true;
--> metier c'est le "name" =)
Merci swoog =)
u're my bill gates