.dsy:it.
Show 150 posts per page

.dsy:it. (http://www.dsy.it/forum/)
- Tech (http://www.dsy.it/forum/forumdisplay.php?forumid=189)
-- [HTML+javascript] perchè da mozilla non funziona? (http://www.dsy.it/forum/showthread.php?threadid=17468)


Posted by 0m4r on 19-02-2005 11:11:

[HTML+javascript] perchè da mozilla non funziona?

come da oggetto, questo è il codice:

code:
<!DOCTYPE HTML SYSTEM "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>test</title> <Link rel="stylesheet" type="text/css" href="bannerDefault.css"/> <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE"> <script type="text/javascript"> function paint(){ var r = document.cp.red.value; var g = document.cp.green.value; var b = document.cp.blue.value; var bw = document.cp.colorbox; var rok = true; var gok = true; var bok = true; if(0>r || r>255){ alert("RED has an INVALID value: it need to be between 0 and 255"); rok = false; } if(0>g || g>255){ alert("GREEN has an INVALID value: it need to be between 0 and 255"); gok = false; } if(0>b || b>255){ alert("BLUE has an INVALID value: it need to be between 0 and 255"); bok = false; } if(rok && gok && bok){ document.getElementById("colorbox").style.backgroundColor='rgb('+r+','+g+','+b+')'; } } function resize(){ var h = document.cp.thumbHeight.value; var w = document.cp.thumbWidth.value; var hok = true; var wok = true; if(h<50 || h>300){ alert("HEIGHT has an INVALID value: it need to be between 50 and 300"); hok = false; } if(w<50 || w>300){ alert("WIDTH has an INVALID value: it need to be between 50 and 300"); wok = false; } if(wok){ document.getElementById("colorbox").style.width=w; alert(document.getElementById("colorbox").style.width); document.getElementById("colorbox").style.width=w; } if(hok){ document.getElementById("colorbox").style.height=h+''; } } </script> </head> <body onload="paint(), resize()"> <form method="post" action="test.html" name="cp"> <table class="gallery"> <tr> <td colspan="2" style="font-weight:bold;"> Dimensioni Icone </td> </tr> <td style="width:50%; text-align:right; border:0px solid blue"> Width : </td> <td style="width:50%; text-align:left; border:0px solid blue"> <input name="thumbWidth" value="250" style="border:1px solid gray" maxlength="3" size="3" onChange="resize()"> px </td> </tr> <tr> <td style="width:50%; text-align:right; border:0px solid blue"> Height : </td> <td style="width:50%; text-align:left; border:0px solid blue"> <input name="thumbHeight" value="150" style="border:1px solid gray" maxlength="3" size="3" onChange="resize()"> px </td> </tr> <tr> <td colspan="2">   </td> </tr> <tr> <td colspan="2" style="font-weight:bold;"> Background </td> </tr> <tr> <td style="width:50%; text-align:right; border:0px solid blue"> Red : </td> <td style="width:50%; text-align:left; border:0px solid blue"> <input name="red" value="255" style="border:1px solid gray; color:red" maxlength="3" size="3" OnKeyUp="paint()"> px </td> </tr> <tr> <td style="width:50%; text-align:right; border:0px solid blue"> Green : </td> <td style="width:50%; text-align:left; border:0px solid blue"> <input name="green" value="200" style="border:1px solid gray; color:green" maxlength="3" size="3" OnKeyUp="paint()"> px </td> </tr> <tr> <td style="width:50%; text-align:right; border:0px solid blue"> Blue : </td> <td style="width:50%; text-align:left; border:0px solid blue"> <input name="blue" value="180" style="border:1px solid gray; color:blue" maxlength="3" size="3" OnKeyUp="paint()"> px </td> </tr> <tr> <td colspan="2" style="font-weight:bold;">   </td> </tr> <tr> <td colspan="2" style="font-weight:bold;"> Preview </td> </tr> <tr> <td colspan="2" align="center"> <div id="colorbox" style="border:1px solid red;">   </div> </td> </tr> </table> </form> </body> </html>

__________________
http://www.twitter.com/0m4r


Posted by yeah on 19-02-2005 22:17:

1) Quando, in resize(), cambi le dimensioni, oltre al valore della variabile aggiungi "px" (es [...].width = w + "px"; )
2) Nello stile del colorbox aggiungi i parametri che cambi nel codice java script: width, height e backgroundColor e assegna valori di default

Dimmi se va :)

__________________
?


Posted by 0m4r on 20-02-2005 12:36:

Originally posted by yeah
1) Quando, in resize(), cambi le dimensioni, oltre al valore della variabile aggiungi "px" (es [...].width = w + "px"; )


FANTASTICO, funziona. Anche se mi sembra un'assurdità non vederlo funzionare semplicemente per l'unità di misura. Comunque ora va!

Originally posted by yeah
2) Nello stile del colorbox aggiungi i parametri che cambi nel codice java script: width, height e backgroundColor e assegna valori di default

La funziona che mi colora il <div> funzionava anche prima, quindi problema risolto gia in partenza!


Originally posted by yeah
Dimmi se va :)

Va!

__________________
http://www.twitter.com/0m4r


Posted by yeah on 20-02-2005 20:39:

Perfetto :)

__________________
?


All times are GMT. The time now is 14:21.
Show all 4 posts from this thread on one page

Powered by: vBulletin Version 2.3.1
Copyright © Jelsoft Enterprises Limited 2000 - 2002.