»
EnglishFrenchVietnamese

Print - Form background color Chooser - JavaScriptBank.com

Full version: jsB@nk » Form » Table » Form background color Chooser
URL: https://www.javascriptbank.com/form-background-color-chooser.html

Form background color Chooser © JavaScriptBank.comVisitors can change color of form through this JavaScript.

Full version: jsB@nk » Form » Table » Form background color Chooser
URL: https://www.javascriptbank.com/form-background-color-chooser.html



JavaScript
<SCRIPT>//detecting browser to dynamically write appropriate DIVs/LAYERsN=(navigator.appName.indexOf('Netscape')!=-1&&parseInt(navigator.appVersion)<5)S=(navigator.appName.indexOf('Netscape')!=-1&&parseInt(navigator.appVersion)>4.9)M=(navigator.appName.indexOf('Microsoft')!=-1)Vis=new Array()Vis[0]=(M||S) ? "hidden" : "hide"Vis[1]=(M||S) ? "visible" : "show"function GetDiv(divId,divY,divX,divW,divH,bCol,visb,zInd){bkCol=(bCol!="")?((N)?" bgColor="+bCol:";background:"+bCol):""Styl = (M||S) ? "<DIV" : "<LAYER"if(M||S){Styl+=" ID="+divIdStyl+=" style='position:absolute;top:"+divY+";left:"+divX+";width:"+divW+";height:"+divH+bkColStyl+=";visibility:"+Vis[visb]+";z-index:"+zIndStyl+="'>"}if(N){Styl+=" ID="+divIdStyl+=" top="+divY+" left="+divX+" width="+divW+" height="+divH+bkColStyl+=" visibility="+Vis[visb]+" z-index="+zIndStyl+=">"}document.writeln(Styl)}function EndDiv(){(M||S)? document.writeln("</DIV>"): document.writeln("</LAYER>")}function PutIt(ID,dX,dY){if(N){document.layers[ID].left=dXdocument.layers[ID].top=dY}if(M){document.all[ID].style.left=dXdocument.all[ID].style.top=dY}if(S){document.getElementById(ID).style.left=dXdocument.getElementById(ID).style.top=dY}}function ShowHide(ID,vs){if(N){document.layers[ID].visibility=Vis[vs]}if(M){document.all[ID].style.visibility=Vis[vs]}if(S){document.getElementById(ID).style.visibility=Vis[vs]}}function Xof(ID){if(N){return document.layers[ID].left}if(M){return document.all[ID].style.left}if(S){return document.getElementById(ID).style.left}}function Yof(ID){if(N){return document.layers[ID].top}if(M){return document.all[ID].style.top}if(S){return document.getElementById(ID).style.top}}function Zind(ID,zz){if(N){document.layers[ID].zIndex=zz}if(M){document.all[ID].style.zIndex=zz}if(S){document.getElementById(ID).style.zIndex=zz}}function ChangeCol(ID,colrx){if(M)document.all[ID].style.background=colrxif(N)document.layers[ID].bgColor=colrxif(S)document.getElementById(ID).style.background=colrx}function DivWrite(IdName,Str) {if (N){document.layers[IdName].document.write(Str)document.layers[IdName].document.close()}if(M) document.all[IdName].innerHTML=Strif(S) document.getElementById(IdName).innerHTML=Str}</SCRIPT><SCRIPT>BoysNames=new Array("Tom","Dick","Harry","James","Keanu","Gareth","Kenneth","John")GalsNames=new Array("Jane","Cathy","Helen","Kim","Anna","Jackie","Deborah","Winnie")SafeColors=new Array("#FF0000","#00FFFF","#CCCCFF","#FFFFFF","#CCFF00","#FFFF00","#CC00FF","#FF9933","#0000FF")ColorNames=new Array("Black","Silver","Gray","White", "Maroon","Red","Purple","Fuchsia",  "Green","Lime","Olive","Yellow","Navy","Blue","Teal","Aqua" )</SCRIPT><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


HTML
<SCRIPT>GetDiv("InputForm",50,50,200,200,'gold',1,1)document.write("<center><form><b>THE FORM</b><p>Name : <input name=Text1><p>")document.write("Email : <input name=Text2><p>")document.write("<input type=button value='Choose Form Color' onclick='ShowHide(\"ColorChart\",1)'>")document.write("</form></center>")EndDiv()GetDiv("ColorChart",170,250,70,70,'black',0,2)document.write("<table border=0 cellspacing=1>")for(cl=0;cl<9;cl++){if(cl%3==0)document.write("<tr>")document.write("<td bgcolor="+SafeColors[cl]+"><a href='javascript:;' onclick='ColorIs(\""+SafeColors[cl]+"\")'><img src=blank.gif width=20 height=20 border=0></a>")}document.write("</table>")EndDiv()function ColorIs(x){if(N){document.layers['InputForm'].bgColor=x}if(M){document.all['InputForm'].style.background=x}if(S){document.getElementById('InputForm').style.background=x}ShowHide("ColorChart",0)}</SCRIPT><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->