IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

JavaScript Discussion :

colorer l'option d'une balise select


Sujet :

JavaScript

  1. #41
    Membre régulier
    Profil pro
    Inscrit en
    Juillet 2005
    Messages
    487
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2005
    Messages : 487
    Points : 113
    Points
    113
    Par défaut
    SUPER merci pour ta ténacité

  2. #42
    Rédacteur/Modérateur

    Avatar de SpaceFrog
    Homme Profil pro
    Développeur Web Php Mysql Html Javascript CSS Apache - Intégrateur - Bidouilleur SharePoint
    Inscrit en
    Mars 2002
    Messages
    39 640
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 74
    Localisation : Royaume-Uni

    Informations professionnelles :
    Activité : Développeur Web Php Mysql Html Javascript CSS Apache - Intégrateur - Bidouilleur SharePoint
    Secteur : Industrie

    Informations forums :
    Inscription : Mars 2002
    Messages : 39 640
    Points : 66 669
    Points
    66 669
    Billets dans le blog
    1
    Par défaut
    40 posts !
    respect

  3. #43
    Rédacteur

    Avatar de Bovino
    Homme Profil pro
    Développeur Web
    Inscrit en
    Juin 2008
    Messages
    23 647
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 53
    Localisation : France, Gironde (Aquitaine)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juin 2008
    Messages : 23 647
    Points : 91 220
    Points
    91 220
    Billets dans le blog
    20
    Par défaut

    J'essaye de te rattraper !

  4. #44
    Membre régulier
    Profil pro
    Inscrit en
    Juillet 2005
    Messages
    487
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2005
    Messages : 487
    Points : 113
    Points
    113
    Par défaut
    oupss!!

    une derniere chose comment on change la couleur bleu foncé de fond par defaut a tout les navigateurs celle qu'on voit quand on passe avec la souris d'une option a l'autre.

  5. #45
    Rédacteur/Modérateur

    Avatar de SpaceFrog
    Homme Profil pro
    Développeur Web Php Mysql Html Javascript CSS Apache - Intégrateur - Bidouilleur SharePoint
    Inscrit en
    Mars 2002
    Messages
    39 640
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 74
    Localisation : Royaume-Uni

    Informations professionnelles :
    Activité : Développeur Web Php Mysql Html Javascript CSS Apache - Intégrateur - Bidouilleur SharePoint
    Secteur : Industrie

    Informations forums :
    Inscription : Mars 2002
    Messages : 39 640
    Points : 66 669
    Points
    66 669
    Billets dans le blog
    1
    Par défaut
    pas accessible avec javascript c'est dans les paramètres de l'os ...
    en général par défaut c'est la couleur complémentaire ...

  6. #46
    Membre régulier
    Profil pro
    Inscrit en
    Juillet 2005
    Messages
    487
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2005
    Messages : 487
    Points : 113
    Points
    113
    Par défaut
    ok

  7. #47
    Rédacteur/Modérateur

    Avatar de SpaceFrog
    Homme Profil pro
    Développeur Web Php Mysql Html Javascript CSS Apache - Intégrateur - Bidouilleur SharePoint
    Inscrit en
    Mars 2002
    Messages
    39 640
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 74
    Localisation : Royaume-Uni

    Informations professionnelles :
    Activité : Développeur Web Php Mysql Html Javascript CSS Apache - Intégrateur - Bidouilleur SharePoint
    Secteur : Industrie

    Informations forums :
    Inscription : Mars 2002
    Messages : 39 640
    Points : 66 669
    Points
    66 669
    Billets dans le blog
    1
    Par défaut
    Maintenant si tu veux vraiment tout paramétrer, il existe des selects émulés à base de ul et de li ...
    du coup les ul et li acceptant le onmouseover tu fais ce que tu veux ...

  8. #48
    Expert confirmé
    Avatar de le_chomeur
    Profil pro
    Développeur informatique
    Inscrit en
    Février 2006
    Messages
    3 653
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Février 2006
    Messages : 3 653
    Points : 4 835
    Points
    4 835
    Par défaut
    ha ben tu me coupes l'herbe sous le pied spaffy

    voila ce que j'avais commencé il y a quelques temps :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Document sans nom</title>
    <style type="text/css">
    #contenu{
    	background-color:#FFFFFF;
    	list-style:none;
    	margin:0px;
    	padding:0px;
    	overflow-x:hidden;
    	overflow-y:auto;
    }
    #contenu li{
    	display:block;
    	clear:both;
    }
    .ItemSelected{
    	background-color:#00FF00;
    }
    .SpanitemSelected{
    	border-left:1px solid #dbdfe6;
    	border-right:1px solid #dbdfe6;
    	border-bottom:1px solid #dbdfe6;
    	border-top:1px solid #abadb3;
    	display:block;
    	font-size:small;
    	background-image:url(bgBoxSelect.jpg);
    	background-position:top right;
    	background-repeat:no-repeat;
    	padding:1px;
    	overflow-y:hidden;
    	height:16px;
     
    }
     
    .SpanitemSelectedHover{
    	border-left:1px solid #c7e2f1;
    	border-right:1px solid #5794bf;
    	border-bottom:1px solid #c7e2f1;
    	border-top:1px solid #5794bf;
    	display:block;
    	font-size:small;
    	background-image:url(bgBoxSelectHover.jpg);
    	background-position:top right;
    	background-repeat:no-repeat;
    	padding:1px;
    	overflow-y:hidden;
    	height:16px;
    }
    .NoSelected{
    	background-color:#ffffff;
    }
    #contenant{
    	overflow:hidden;
    	position:absolute;
    	height:0px;
    	width:200px;
    	background-color:#FFFFFF;
    	border-left:1px solid #b2b2b2;
    	border-right:1px solid #000000;
    	border-bottom:1px solid #000000;
    	border-top:1px solid #b2b2b2;
    	visibility:hidden;
    	margin-top:1px
    }
    .OverItem{
    	background-color:#3399ff;
    	color:#FFFFFF;
    }
    .OutItem{
    	background-color:#FFFFFF;
    	color:#000000;
    }
     
    </style>
    <script type="text/javascript">
    var MonTimer = null;
    var Debut = null;
    var elem = null;
    var ajoutX = null;
    var ajoutY = null;
    var X = 0 ;
    var objModif;
     
    function initAnimation(Ynew){
    	objModif = document.getElementById('contenant');
    	objModif.style.visibility = 'visible';
    	var Yold = parseInt(document.getElementById('contenant').style.height) ;
    	//On détruit le timer s'il existe
    	clearTimeout(MonTimer);
    	elem = document.getElementById('contenant');
    	ajoutY = (Ynew >= Yold) ? true:false;
    	var ie=document.all;
    	divAnime(Ynew,Yold);
     
     
    }
    function divAnime(Ynew,Yold){
    	X++;
    	//si Ynew > Yold
    	if(parseInt(elem.style.height) < Ynew && ajoutY){
    		elem.style.height = (parseInt(elem.style.height)  + 10)+"px";
    	}
    	//si Xnew < Xold
    	else if(parseInt(elem.style.height) > Ynew){
    		elem.style.height = (parseInt(elem.style.height)  - 10 )+"px";
    	}
    	else{
    		elem.style.height = Ynew +"px";
    	}
     
    	TailleFinaleY = (parseInt(elem.style.height) == Ynew) ? true:false;
     
    	if(!TailleFinaleY){
    		MonTimer = setTimeout ('divAnime('+Ynew+','+Yold+')',1);					
    	}
    	else{
    		//On tue le timer
    		elem.style.height = ((ajoutY) ? Ynew:0) +"px";
    		objModif.style.visibility = ((ajoutY) ? 'visible':'hidden');
    		clearTimeout(MonTimer);
    	}
     
    }
     
    function ajouterLi(TextToAdd,indexItem){
    		var d = document;
    		var NewLi =	d.createElement('li');
    		var NewTexte = d.createTextNode(TextToAdd);
    		//Ajout du texte de l'item de la liste
    		NewLi.appendChild(NewTexte);
    		NewLi.onclick = function(){selectItem(indexItem,this)};
    		NewLi.onmouseover = function(){overStyle(this,"over")};
    		NewLi.onmouseout = function(){overStyle(this,"out")};
    		var objUL  = document.getElementById( 'contenu' );
    		//On ajoute l'item en tout premier
    		objUL.appendChild(NewLi);
    	}
    function selectItem(indexItem,ItemToSelect){
    	var MesLi = document.getElementById("contenu").getElementsByTagName("li");
    	var nbOption= MesLi.length;
    	for(var i = 0 ; i < nbOption ; i++){
    		MesLi[i].className = "NoSelected";
    	}
    	ItemToSelect.className = "ItemSelected";
    	document.getElementById('desItems').selectedIndex = indexItem;
    	document.getElementById('SpanitemSelected').getElementsByTagName('span')[0].innerHTML = ItemToSelect.innerHTML;
    	initAnimation(0);
    }
     
    function overStyle(ItemToSelect,mode)
    {
    	if(mode == "over" && ItemToSelect.className != "ItemSelected")
    	{
    		ItemToSelect.className = "OverItem";
    	}
    	else if(mode == "out" && ItemToSelect.className != "ItemSelected")
    	{
    		ItemToSelect.className = "OutItem";
    	}
    }
    </script>
    </head>
     
    <body>
    <div href="#" style="position:relative;cursor:pointer;width:150px;float:left;" id="toto" onmouseover="initAnimation(document.getElementById('contenu').offsetHeight)" onmouseout="initAnimation(0)">
    <span id="SpanitemSelected" class="SpanitemSelected" onclick="initAnimation(document.getElementById('contenu').offsetHeight)" onmouseover="this.className ='SpanitemSelectedHover'" onmouseout="this.className='SpanitemSelected'"><span style="display:block;width:90%;overflow:hidden">Selectionner une option</span></span>
    <div id="contenant" style="height:0px;">
    	<ul id="contenu">
        </ul>
    </div>
    </div>
    <select id="desItems">
    	<option value="Item 1">Item 1 et la un truc super grand ça donne quoi ça merde ?</option>
        <option value="Item 2">Item 2</option>
        <option value="Item 3">Item 3</option>
        <option value="Item 4">Item 4</option>
        <option value="Item 4">Item 4</option>
        <option value="Item 4">Item 4</option>
    </select><br /><br /><br /><br /><br /><br />
    <div id="debug"></div>
     
    <script type="text/javascript">
    	var MonSelect = document.getElementById("desItems");
    	var nbOption= MonSelect.length;
    	for(var i = 0 ; i < nbOption ; i++){
    		ajouterLi(MonSelect[i].text,i);
    	}
    	document.getElementById('contenu').style.height = (i+1) * 20 + "px";
    	var MonSelect = document.getElementById("toto");
    	//MonSelect.onmouseover = doSomething;
    </script>
    </body>
    </html>

  9. #49
    Membre régulier
    Profil pro
    Inscrit en
    Juillet 2005
    Messages
    487
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2005
    Messages : 487
    Points : 113
    Points
    113
    Par défaut
    messieurs de vous remercie

+ Répondre à la discussion
Cette discussion est résolue.
Page 3 sur 3 PremièrePremière 123

Discussions similaires

  1. Disabled options sur une balise select
    Par Friksstyle dans le forum jQuery
    Réponses: 6
    Dernier message: 28/11/2013, 14h01
  2. Nombre d'option maximum dans une balise select (Bug IE)
    Par Fourche dans le forum Balisage (X)HTML et validation W3C
    Réponses: 4
    Dernier message: 16/12/2008, 15h33
  3. Récupérer le libellé de l'option d'une balise SELECT
    Par tixmcprods dans le forum Général JavaScript
    Réponses: 5
    Dernier message: 21/03/2008, 10h04
  4. ajout éléments dans une balise select
    Par wehtam dans le forum Général JavaScript
    Réponses: 3
    Dernier message: 18/08/2005, 14h03
  5. Réponses: 4
    Dernier message: 18/11/2003, 16h08

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo