Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
4520 connectés 

  FORUM HardWare.fr
  Programmation
  HTML/CSS

  [Formulaire] Changer les options d'un <select>

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

[Formulaire] Changer les options d'un <select>

n°1145317
e-miel
Posté le 10-07-2005 à 02:48:17  profilanswer
 

J'arrive à changer le texte (c-à-d la valeur) d'un <input> texte, bouton... mais je n'arrive pas à changer le texte qui apparaît dans un <select>. Ce qui serait parfait, c'est si je pouvais faire rentrer une liste de chaînes dans un <select> sans dialoguer avec le serveur, uniquement avec un code client (comme du JavaScript).

mood
Publicité
Posté le 10-07-2005 à 02:48:17  profilanswer
 

n°1145520
e-miel
Posté le 10-07-2005 à 15:02:01  profilanswer
 

Pas de réponse ? Si je peux simplement faire disparaître certaines possibilités, ça me suffit. J'attends vos idées !

n°1145525
masklinn
í dag viðrar vel til loftárása
Posté le 10-07-2005 à 15:14:34  profilanswer
 

ya pas de texte dans les <select>, le texte est dans les <option> contenues dans les <select> [:spamafote]


---------------
I mean, true, a cancer will probably destroy its host organism. But what about the cells whose mutations allow them to think outside the box by throwing away the limits imposed by overbearing genetic regulations? Isn't that a good thing?
n°1145533
e-miel
Posté le 10-07-2005 à 15:39:48  profilanswer
 

Oui, ça je sais. Tu saurais désactiver certains <option> ?

n°1145538
masklinn
í dag viðrar vel til loftárása
Posté le 10-07-2005 à 15:42:57  profilanswer
 

tu les supprimes [:spamafote]


---------------
I mean, true, a cancer will probably destroy its host organism. But what about the cells whose mutations allow them to think outside the box by throwing away the limits imposed by overbearing genetic regulations? Isn't that a good thing?
n°1145541
e-miel
Posté le 10-07-2005 à 15:49:32  profilanswer
 

Ouaaaa !!! J'y avais pas pensé !!! Le problème c'est : Comment tu les supprimes ?
 
Je m'explique : j'ai ceci :

<select>
    <option>Bonjour</option>
    <option>Salut</option>
    <option>Au-revoir</option>
</select>

J'aimerais qu'en faisant une action sur la page (par exemple cliquer sur un bouton) ça enlève le choix "Salut", pour ne garder que "Bonjour" et "Au-revoir". Tu sais comment faire ça ?

n°1145544
masklinn
í dag viðrar vel til loftárása
Posté le 10-07-2005 à 15:51:01  profilanswer
 

e-miel a écrit :

Ouaaaa !!! J'y avais pas pensé !!!


J'avais remarqué [:spamafote]

Citation :

Tu sais comment faire ça ?


oui [:spamafote]  


---------------
I mean, true, a cancer will probably destroy its host organism. But what about the cells whose mutations allow them to think outside the box by throwing away the limits imposed by overbearing genetic regulations? Isn't that a good thing?
n°1145545
e-miel
Posté le 10-07-2005 à 15:53:31  profilanswer
 

Tu n'as pas répondu à ma question : "Comment tu les supprimes ?" Ecris-moi simplement le code JavaScript pour faire ça.

n°1145549
masklinn
í dag viðrar vel til loftárása
Posté le 10-07-2005 à 16:01:30  profilanswer
 

Non.
 
par contre je peux te donner la méthode pour le faire

removeChild()
 Removes a child node from an element  
 
x.removeChild(y)
Remove child y of node x.


Message édité par masklinn le 10-07-2005 à 16:01:46

---------------
I mean, true, a cancer will probably destroy its host organism. But what about the cells whose mutations allow them to think outside the box by throwing away the limits imposed by overbearing genetic regulations? Isn't that a good thing?
n°1145556
e-miel
Posté le 10-07-2005 à 16:07:51  profilanswer
 

Ok, je vais tester ça. Merci !

mood
Publicité
Posté le 10-07-2005 à 16:07:51  profilanswer
 

n°1145564
e-miel
Posté le 10-07-2005 à 16:21:07  profilanswer
 

Je n'y arrive pas. Voici ce que j'ai fait :

<select id=sel>
    <option>Bonjour</option>  
    <option id=sal>Salut</option>  
    <option>Au-revoir</option>  
</select>
 
<script>
    document.getElementById('sel').removeChild(document.getElementById('sal'))
</script>

Et toi, tu écrirais quoi ?

n°1145568
e-miel
Posté le 10-07-2005 à 16:25:17  profilanswer
 

Ah, ça marche !
Il suffisait de quitter et de relancer le navigateur, les "Refresh" ne suffisaient pas. Merci pour la fonction, elle me sera très utile !

n°1145580
masklinn
í dag viðrar vel til loftárása
Posté le 10-07-2005 à 16:43:05  profilanswer
 

http://www.quirksmode.org/?/dom/w3c_core.html


---------------
I mean, true, a cancer will probably destroy its host organism. But what about the cells whose mutations allow them to think outside the box by throwing away the limits imposed by overbearing genetic regulations? Isn't that a good thing?

Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  HTML/CSS

  [Formulaire] Changer les options d'un <select>

 

Sujets relatifs
formulaire - insérer un cvchanger le css suivant la résolution client ???
Problème dans mon formulairevérifier qu'un formulaire a été entierement rempli
vbs recuperation d'un multiple selectOrdre de transmission des données d'un formulaire
[INFOPATH] Passer des paramètres à un formulaire infopath?vérification formulaire
[access] Formulaire pour choisir chemin d'acces d'un fichierEnvoie formulaire POST popup
Plus de sujets relatifs à : [Formulaire] Changer les options d'un <select>


Copyright © 1997-2025 Groupe LDLC (Signaler un contenu illicite / Données personnelles)