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 :

choix couleur .


Sujet :

JavaScript

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre éclairé
    Profil pro
    Inscrit en
    Octobre 2005
    Messages
    745
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2005
    Messages : 745
    Par défaut choix couleur .
    Bonjour,
    on m'a dit de venir ici
    Donc voila, je suis actuellement en train de réaliser une sorte de petit web publisher en asp pour une boite je dois arriver a créer dynamiquement de nouvelles pages asp suivant un modele, avec une css, des photos, et tout et tout, Bref jusque la tout va bien mais c'est lorsque pour la création d'un nouveau site, enfin un sous répertoire de mon site, je dois créer une feuille css, du moins faire choisir a un utilisateur une couleur de fond et une couleur de remplissage d'une cellule, bref choper le code couleur coreespondant et crée ma feuille de style, ùalheureusement ce qui me pose probleme c'est comment faire choisir sa couleur a l'utilisateur, j'ai bien vu du coté des color picker, mais ceux trouver sur le net je n'arrive pas a les lancer.
    bref si quelqu'un pouvait me donner un ti coup de main ^^ je lui en serais extrement reconnaissant.
    D'avance MERCI!!!

  2. #2
    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 659
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 75
    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 659
    Billets dans le blog
    1
    Par défaut
    j'ai ça en stock entre autres...

    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
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    <HTML>
    	<HEAD>
    		<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
            <style> 
    			.Scroll{ 
    				FONT-SIZE: 1px; 
    				OVERFLOW-X: scroll; 
    				WIDTH: 100px; 
    				HEIGHT: 0px;
    			} 
    		</style> 
     
    	</HEAD>
    	<body onload="InitPage();getColor();">
    		<script language="javascript">
    			/******************************************************************
    				This code can be used but, please, keep this reference
    				©2004 www.manutrix.com
    			*******************************************************************/
    			var arrScroll = new Array();
    			var arrText = new Array();
     
    			function InitPage(){
    				arrScroll[0] = document.getElementById('scrollRed');
    				arrScroll[1] = document.getElementById('scrollGreen');
    				arrScroll[2] = document.getElementById('scrollBlue');
    				arrScroll[3] = document.getElementById('scrollHue');
    				arrScroll[4] = document.getElementById('scrollSat');
    				arrScroll[5] = document.getElementById('scrollLum');			
     
    				arrText[0] = document.getElementById('txtRed');
    				arrText[1] = document.getElementById('txtGreen');
    				arrText[2] = document.getElementById('txtBlue');
    				arrText[3] = document.getElementById('txtHue');
    				arrText[4] = document.getElementById('txtSat');
    				arrText[5] = document.getElementById('txtLum');
    			}
    			function scrollState(Obj,Action){
    				for(iLoop=0; iLoop<arrScroll.length; iLoop++){
    					arrScroll[iLoop].onscroll =	arrScroll[iLoop].Categorie==Obj.Categorie || Action==2?//if
    												arrScroll[iLoop].Categorie==1?function(){setTextValue(this);toHSL();}:function(){setTextValue(this);toRGB();}://then
    												"";//else
    				}
    			}
     
    			function textState(Obj,Action){
    				var objScrollId = document.getElementById("scroll" + (Obj.id).substring(3,(Obj.id).length));
    				if(Action==1)Obj.select();
     
    				scrollState(objScrollId,Action)
    				Obj.onkeyup =	Action==1?//if
    								function(){objScrollId.scrollLeft = Obj.value;}://then
    								"";//else
    			}
     
    			function setTextValue(Obj){
    				var TextId = "txt" + (Obj.id).substring(6,(Obj.id).length);
    				document.getElementById(TextId).value = Obj.scrollLeft;
    			}
     
    			function setScrollValue(Obj){
    				var TextId = "txt" + (Obj.id).substring(6,(Obj.id).length);
    				document.getElementById(TextId).value = Obj.scrollLeft;
    			}
     
    			function getColor(){
    				var Red = document.getElementById('txtRed').value;
    				var Green = document.getElementById('txtGreen').value;
    				var Blue = document.getElementById('txtBlue').value;
     
    				document.getElementById('resColor').style.backgroundColor = '#' + toHexa(Red) + toHexa(Green) + toHexa(Blue);
    			}
     
    			function toHexa(num){
    				num -= 0
    				hexChars = "0123456789ABCDEF"
     
    				if (num > 255) {
    					return null
    				}
    				var i = num % 16
    				var j = (num - i) / 16
    				result = hexChars.charAt(j)
    				result += hexChars.charAt(i)
    				return result
    			}
     
    			function toHSL(){
    				// Code converted from vb --> http://abstractvb.com/code.asp?A=927
    				var Hue;
    				var Sat;
    				var Lum;
     
    				var Red = arrText[0].value/255;
    				var Green = arrText[1].value/255;
    				var Blue = arrText[2].value/255;
     
    				var Min = Math.min(Red, Math.min(Green, Blue))
    				var Max = Math.max(Red, Math.max(Green, Blue))
     
    				Lum = (Max + Min) / 2;
     
    				if(Max == Min){
    					Hue = 0;
    					Sat = 0;
    				}
    				else{
    					if(Lum < 0.5)
    						Sat = (Max - Min) / (Max + Min);
    					else
    						Sat = (Max - Min) / (2 - Max - Min);
     
    					switch(Max){
    						case Red:
    							Hue = (Green - Blue) / (Max - Min);
    							break;
    						case Green:
    							Hue = 2 + (Blue - Red) / (Max - Min);
    							break;
    						case Blue:
    							Hue = 4 + (Red - Green) / (Max - Min);
    							break;
    					}
    				}
     
    				Hue = (Hue * 239) / 6;
     
    				if(Hue < 0)
    					Hue = Hue + 240
    				Sat *= 239;
    				Lum *= 239;
     
    				arrScroll[3].scrollLeft = Math.round(Hue);
    				arrScroll[4].scrollLeft = Math.round(Sat);
    				arrScroll[5].scrollLeft = Math.round(Lum);
     
    				arrText[3].value = Math.round(Hue);
    				arrText[4].value = Math.round(Sat);
    				arrText[5].value = Math.round(Lum);
     
    				getColor()
    			}
     
    			function toRGB(){
    				// Code converted from vb --> http://abstractvb.com/code.asp?A=926
    				var Red;
    				var Green;
    				var Blue;
     
    				var temp1;
    				var temp2;
    				var temp3 = new Array();
     
    				var Hue = arrText[3].value / 239;
    				var Sat = arrText[4].value / 239;
    				var Lum = arrText[5].value / 239;
     
    				if(Sat == 0){
    					Red = Lum;
    					Green = Lum;
    					Blue = Lum;
    				}
    				else{
    					if(Lum < 0.5)
    						temp2 = Lum * (1 + Sat);
    					else
    						temp2 = Lum + Sat - Lum * Sat;
     
    					temp1 = 2 * Lum - temp2;
     
    					temp3[0] = Hue + 1 / 3;
    					temp3[1] = Hue;
    					temp3[2] = Hue - 1 / 3;
     
    					for(iLoop=0; iLoop<3;iLoop++){
    						if(temp3[iLoop] < 0) temp3[iLoop] = temp3[iLoop] + 1;
    					 	if(temp3[iLoop] > 1) temp3[iLoop] = temp3[iLoop] - 1;
     
    						if(6 * temp3[iLoop] < 1)
    							temp3[iLoop] = temp1 + (temp2 - temp1) * 6 * temp3[iLoop];
    						else
    							if(2 * temp3[iLoop] < 1)
    								temp3[iLoop] = temp2;
    							else
    								if(3 * temp3[iLoop] < 2)
    									temp3[iLoop] = temp1 + (temp2 - temp1) * ((2 / 3) - temp3[iLoop]) * 6;
    								else
    									temp3[iLoop] = temp1
    					}
     
    				   Red = temp3[0]
    				   Green = temp3[1]
    				   Blue = temp3[2]
    				}
     
    				Red = Red * 255
    				Green = Green * 255
    				Blue = Blue * 255
     
    				arrScroll[0].scrollLeft = Math.round(Red);
    				arrScroll[1].scrollLeft = Math.round(Green);
    				arrScroll[2].scrollLeft = Math.round(Blue);
     
    				arrText[0].value = Math.round(Red);
    				arrText[1].value = Math.round(Green);
    				arrText[2].value = Math.round(Blue);
     
    				getColor()
    			}
     
    		</script>
    		<form>
    			<table>
    				<tr>
    					<td>
    						<table>
    							<tr>
    								<td>Red:</td>
    								<td><input id="txtRed" onfocus="textState(this,1)" onblur="textState(this,2)" type="text" maxLength="3" size="3" value="0"></td>
    								<td width="50" valign="top">
    									<div id="scrollRed" Categorie="1" OnMouseOver="scrollState(this,'1')" onmouseout="scrollState(this,'2')" class="Scroll">
    										<div style="WIDTH: 355px"></div>
    									</div>
    								</td>
    							</tr>
    							<tr>
    								<td>Green:</td>
    								<td><input id="txtGreen" onfocus="textState(this,1)" onblur="textState(this,2)" type="text" maxLength="3" size="3" value="0"></td>
    								<td width="50" valign="top">
    									<div id="scrollGreen" Categorie="1" OnMouseOver="scrollState(this,'1')" onmouseout="scrollState(this,'2')" class="Scroll">
    										<div style="WIDTH: 355px"></div>
    									</div>
    								</td>
    							</tr>
    							<tr>
    								<td>Blue:</td>
    								<td><input id="txtBlue" onfocus="textState(this,1)" onblur="textState(this,2)" type="text" maxLength="3" size="3" value="0"></td>
    								<td width="50" valign="top">
    									<div id="scrollBlue" Categorie="1" OnMouseOver="scrollState(this,'1')" onmouseout="scrollState(this,'2')" class="Scroll">
    										<div style="WIDTH: 355px"></div>
    									</div>
    								</td>
    							</tr>
    							<tr>
    								<td colspan="3"><hr>
    								</td>
    							</tr>
    							<tr>
    								<td>Hue:</td>
    								<td><input type="text" onfocus="textState(this,1)" onblur="textState(this,2)" id="txtHue" maxlength="3" size="3" value="0"></td>
    								<td width="100" valign="top">
    									<div id="scrollhue" Categorie="2" OnMouseOver="scrollState(this,'1')" onmouseout="scrollState(this,'2')" class="Scroll">
    										<div style="WIDTH:339px"></div>
    									</div>
    								</td>
    							</tr>
    							<tr>
    								<td>Sat:</td>
    								<td><input type="text" onfocus="textState(this,1)" onblur="textState(this,2)"  id="txtSat" maxlength="3" size="3" value="0"></td>
    								<td width="100" valign="top">
    									<div id="scrollSat" Categorie="2" OnMouseOver="scrollState(this,'1')" onmouseout="scrollState(this,'2')" class="Scroll">
    										<div style="WIDTH:339px"></div>
    									</div>
    								</td>
    							</tr>
    							<tr>
    								<td>Lum:</td>
    								<td><input type="text" onfocus="textState(this,1)" onblur="textState(this,2)" id="txtLum" maxlength="3" size="3" value="0"></td>
    								<td width="100" valign="top">
    									<div id="scrollLum" Categorie="2" OnMouseOver="scrollState(this,'1')" onmouseout="scrollState(this,'2')" class="Scroll">
    										<div style="WIDTH:339px"></div>
    									</div>
    								</td>
    							</tr>
    						</table>
    					</td>
    					<td width="10">&nbsp;</td>
    					<td width="100" height="100%" colSpan="2">
    						<table width="100%" height="100%">
    							<tr height="50%">
    								<td id="resColor">
    								</td>
    							</tr>
    							<tr height="50%">
    								<td>
    								</td>
    							</tr>
    						</table>
    					</td>
    				</tr>
    			</table>
    		</form>
    	</body>
    </HTML>
    Ma page Developpez - Mon Blog Developpez
    Président du CCMPTP (Comité Contre le Mot "Problème" dans les Titres de Posts)
    Deux règles du succès: 1) Ne communiquez jamais à quelqu'un tout votre savoir...
    Votre post est résolu ? Alors n'oubliez pas le Tag

    Venez sur le Chat de Développez !

  3. #3
    Membre éclairé
    Profil pro
    Inscrit en
    Octobre 2005
    Messages
    745
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2005
    Messages : 745
    Par défaut
    je testerai ca demain merci beaucoup quand meme!!

Discussions similaires

  1. Site choix couleur
    Par Devilju69 dans le forum Langage
    Réponses: 3
    Dernier message: 02/06/2008, 15h44
  2. [CR XI] Graphiques - choix couleur ?
    Par kikidrome dans le forum SAP Crystal Reports
    Réponses: 2
    Dernier message: 04/02/2008, 11h28
  3. Pb choix couleur ListBox
    Par Remtimes dans le forum 4D
    Réponses: 1
    Dernier message: 31/08/2007, 11h49
  4. Choix couleur fond des composants
    Par Mihalis dans le forum Delphi
    Réponses: 14
    Dernier message: 13/06/2007, 09h21
  5. asp choix couleurs
    Par Alex35 dans le forum ASP
    Réponses: 9
    Dernier message: 04/01/2007, 14h35

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