»
EnglishFrenchVietnamese

Print - Change color by calculating - JavaScriptBank.com

Full version: jsB@nk » Background » Change color by calculating
URL: https://www.javascriptbank.com/change-color-by-calculating.html

Change color by calculating © JavaScriptBank.comThis JavaScript requests two numbers from you to change background color by calculating one of the basic operations.

Full version: jsB@nk » Background » Change color by calculating
URL: https://www.javascriptbank.com/change-color-by-calculating.html



JavaScript
<script language="javascript">/*     This script downloaded from www.JavaScriptBank.com     Come to view and download over 2000+ free javascript at www.JavaScriptBank.com*/document.bgColor="violet"function add(){var a,b,sum;a=eval(document.form1.t1.value);b=eval(document.form1.t2.value);sum=a+b;document.form1.t3.value=sum;document.form1.t4.value="";document.form1.t5.value="";document.form1.t6.value="";document.bgColor="red"}function mult(){var k,h,mult;k=eval(document.form1.t1.value);h=eval(document.form1.t2.value);mult=k*h;document.form1.t4.value=mult;document.form1.t3.value="";document.form1.t5.value="";document.form1.t6.value="";document.bgColor="green"}function sub(){var k,h,sub;k=eval( document.form1.t1.value);h=eval(document.form1.t2.value);sub=k-h;document.form1.t5.value=sub;document.form1.t4.value="";document.form1.t3.value="";document.form1.t6.value="";document.bgColor="blue"}function div(){var k,h,div;document.bgcolor="#ffff00";k=eval( document.form1.t1.value);h=eval(document.form1.t2.value);div=k/h;document.form1.t6.value=div;document.form1.t5.value="";document.form1.t4.value="";document.form1.t3.value="";document.bgColor="yellow"}function c(){document.bgColor="violet"}</script><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


HTML
<form name="form1" style="text-align: left;"><font color="#008000" size="5">Just enter two mumbers... and click the appropriate buttons for&nbsp; results</font><p>Enter the first number:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input type="text" name="t1" size="20"><br>Enter the second number:  <input type="text" name="t2" size="20"><br><input type="button" name="b1" value="   ADD  " onclick="add()"><input type="text" name="t3" size="20">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" name="b2" value="MULTIPLY " onclick="mult()"><input type="text" name="t4" size="20"><br><input type="button" name="b3" value=" SUBTRACT " onclick="sub()"><input type="text" name="t5" size="20"><input type="button" name="b4" value=" DIVISION " onclick="div()"><input type="text" name="t6" size="20"><br><input type="reset" name="res" value="CLEAR" onClick="c()"></form><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->