Parentnode d'un <option>

Résolu
themagician67 Messages postés 22 Date d'inscription jeudi 29 novembre 2007 Statut Membre Dernière intervention 26 octobre 2010 - 26 oct. 2010 à 09:31
themagician67 Messages postés 22 Date d'inscription jeudi 29 novembre 2007 Statut Membre Dernière intervention 26 octobre 2010 - 26 oct. 2010 à 09:40
Bonjour,

J'ai une question. J'ai deux "select multiple" et je fais des déplacements de valeurs avec des images de fond dans les options.
Quand on passe du select1 au select2, l'image de fond de l'option change.
Et inversement.
l'option déplacée est créée comme ceci :
var newOpt = new Option(theText, theValue);


Mais pour changer l'image de fond, il faut que je teste dans quel select se trouve l'option :
if(newOpt.parentNode.id == 'sel2'){
 	newOpt.setAttribute("style","background-color:white;background-image:url(../images/billing_2bis.png);background-position: 1px 1px;background-repeat: no-repeat;padding: 0 0 0 20px;margin-left:7px;background-color:#E7E7E7;height:18px");
  }
  else{
newOpt.setAttribute("style","background-color:white;background-image:url(../images/billing.png);background-position: 1px 1px;background-repeat: no-repeat;padding: 0 0 0 20px;margin-left:7px;background-color:#E7E7E7;height:18px");
  }


Or newOpt.parentNode me retourne 'null'. Je ne sais pas pourquoi.
Si quelqu'un a une explication ou une solution, je suis preneur. Merci d'avance.

1 réponse

themagician67 Messages postés 22 Date d'inscription jeudi 29 novembre 2007 Statut Membre Dernière intervention 26 octobre 2010
26 oct. 2010 à 09:40
C'est bon, j'ai trouvé. J'avais inséré la condition au mauvais endroit.
3
Rejoignez-nous