Full version: jsB@nk » Background » ColorAssist
URL: https://www.javascriptbank.com/colorassist.html
Need help choosing the colors for your Web site? ColorAssist helps you with this by displaying any background and font color combination. It will even choose random colors for you and let you save your favorites.
Full version: jsB@nk » Background » ColorAssist
URL: https://www.javascriptbank.com/colorassist.html
<script language="javascript">/* This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com*/// Ryan Sokol ([email protected])<!-- Beginfunction showBGColor(){ if(document.clrForm.bgRandom.checked == true) document.bgColor = document.clrForm.bgColor.value = getRandom(); else { if(document.clrForm.bgColor.value.search(/^#[a-f0-9]{6}$/ig) == -1) alert('Invalid background color'); else document.bgColor = document.clrForm.bgColor.value; }}function showTXTColor(){ if(document.clrForm.txtRandom.checked == true) txtChg.style.color = document.clrForm.txtColor.value = getRandom(); else { if(document.clrForm.txtColor.value.search(/^#[a-f0-9]{6}$/ig) == -1) alert('Invalid font color'); else txtChg.style.color = document.clrForm.txtColor.value; }}var pool = new Array("0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F");function getRandom(){ var clr = ''; for(i=0; i<6; i++) { num = Math.round(Math.random() * (pool.length-1)); clr += pool[num]; } return '#'+ clr;}function saveColor(field){ if(field == "bgColor") // bgColor field opt = document.clrForm.bgColor.value.toUpperCase(); else // txtColor field opt = document.clrForm.txtColor.value.toUpperCase(); if(opt != '') { i = document.clrForm.saveList.options.length; for(j=0; j < i; j++) { if(document.clrForm.saveList.options[j].value == opt) return; } document.clrForm.saveList.options[i] = new Option(opt, opt); document.clrForm.saveList.selectedIndex = i; }}function putColor(field){ if(field == "bgColor") // bgColor field { if(document.clrForm.saveList.selectedIndex >= 0) { document.clrForm.bgRandom.checked = false; document.clrForm.bgColor.value = document.clrForm.saveList.options[document.clrForm.saveList.selectedIndex].value; showBGColor(); } } else // txtColor field { if(document.clrForm.saveList.selectedIndex >= 0) { document.clrForm.txtRandom.checked = false; document.clrForm.txtColor.value = document.clrForm.saveList.options[document.clrForm.saveList.selectedIndex].value; showTXTColor(); } }}// End --></script><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->
<form name="clrForm"><table bgcolor="white" border="1"><tbody><tr> <td align="left" valign="top"><font face="verdana" size="-1"> <b>Background Color:</b><br> <input type="text" name="bgColor" value="#FFFFFF" size="8" maxlength="7" onkeyup="document.clrForm.bgRandom.checked=false;"> <input type="button" name="addBG" value="save ->" onclick="saveColor('bgColor');"><br> <input type="checkbox" name="bgRandom" value="ON"> random<br> <input type="button" value="Display" onclick="showBGColor()"> </font> </td> <td align="center" valign="top"><font face="verdana" size="-1"> <b>Saved List:</b><br> <select name="saveList" size="2"></select><br> <input type="button" name="fillBG" value="<- put" onclick="putColor('bgColor');"> <input type="button" name="fillTXT" value="put ->" onclick="putColor('txtColor');"> </font> </td> <td align="right" valign="top"><font face="verdana" size="-1"> <b>Font Color:</b><br> <input type="button" name="addTXT" value="<- save" onclick="saveColor('txtColor');"> <input type="text" name="txtColor" value="#000000" size="8" maxlength="7" onkeyup="document.clrForm.txtRandom.checked=false;"><br> <input type="checkbox" name="txtRandom" value="ON"> random<br> <input type="button" value="Display" onclick="showTXTColor()"> </font> </td></tr></tbody></table><h5 id="txtChg" align="center">Make your choices above</h5></form><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->