Ver Mensaje Individual
  #1 (permalink)  
Antiguo 05/09/2008, 09:55
Angelus07
 
Fecha de Ingreso: abril-2007
Ubicación: Buenos Aires
Mensajes: 49
Antigüedad: 17 años, 1 mes
Puntos: 0
Select color con javascript

cómo podría hacer que la tabla de colores sea emergente???

Código HTML:
<style>
.ColorCell{width: 3; height: 3}
.GradientColorCell{width: 5; height: 20}
</style>
<script>
function Hexa(Dec){
var nb = Dec.toString(16)
if (nb.length < 2) {nb = "0" + nb}
return(nb)
}
function GradientPart(dr, dg, db, fr, fg, fb, Step) {
cr=dr;cg=dg;cb=db
sr=((fr-dr)/Step)
sg=((fg-dg)/Step)
sb=((fb-db)/Step)
var Result = ''
for (var x = 0; x <= Step; x++) {
var cmd = " onclick=\"ColorCode.value=this.bgColor;\" onmouseover=\"ColorShow.style.backgroundColor=this.bgColor;\""
Result += "<TD CLASS=ColorCell BGCOLOR=#" + Hexa(Math.floor(cr)) + Hexa(Math.floor(cg)) + Hexa(Math.floor(cb)) + cmd + "></TD>"
cr += sr; cg += sg; cb += sb
}
return(Result)
}
function WriteRow(a,i){
document.write("<TR>")
document.write(GradientPart(a,i,i, a,a,i, StepH))
document.write(GradientPart(a,a,i ,i,a,i, StepH))
document.write(GradientPart(i,a,i, i,a,a, StepH))
document.write(GradientPart(i,a,a, i,i,a, StepH))
document.write(GradientPart(i,i,a, a,i,a, StepH))
document.write(GradientPart(a,i,a, a,i,i, StepH))
document.write("</TR>")
}
</script>

<TABLE>
<TR>
<TD COLSPAN=2>
<script>
document.write("<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 STYLE='border: 1px solid black'>")
StepH = 20
var StepV = 8
var i=0
var a=0
for (a=0;a<=255; a+=StepV){
WriteRow(a,i)
}
a=255
for (i=0; i<=255; i+=StepV){
WriteRow(a,i)
}
document.write("</TABLE>")
</script>
</TD>
</TR>
<TR>
<TD>
<DIV ID=ColorShow STYLE="width: 100; height: 60; border: 1px solid black"></DIV>
</TD>
<TD>
Codigo de color : <INPUT ID=ColorCode TYPE=text SIZE=8>
</TD>
</TR>
</TABLE>