PDA

View Full Version : JavaScript Collector



JavaScriptBank
09 Jul 2009, 03:28 AM
JavaScript Collector

Change color by calculating

This JavaScript (http://www.javascriptbank.com/javascript/) requests two numbers from you to change background color (http://www.javascriptbank.com/javascript/background/) by calculating one of the basic operations.... detail (http://www.javascriptbank.com/change-color-by-calculating.html)


http://www.javascriptbank.com/javascript.images/background/change-color-by-calculating.jpg (http://www.javascriptbank.com/change-color-by-calculating.html)
Demo: Change color by calculating (http://www.javascriptbank.com/javascript/background/change-color-by-calculating/preview/)

How to setup

Step 1: Copy & Paste JavaScript code below in your HEAD section
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
-->


Step 2: Place HTML below in your BODY section
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
-->




Some related scripts
- Change Color onMouseover (http://www.javascriptbank.com/change-color-onmouseover.html)
- Change color onMouseover (http://www.javascriptbank.com/change-color-onmouseover-link.html)
You can browse some JavaScript codes about Background (http://www.javascriptbank.com/javascript/background/)





DHTML,JavaScript Tutorials (http://www.javascriptbank.com/thietkeweb/javascriptmall/contents.htm) - Free JavaScript eBooks (http://www.javascriptbank.com/forum/viewforum.php?f=13) - DHTMl, CSS, JavaScript eBooks Download (http://www.javascriptbank.com/forum/viewforum.php?f=13)


The Site may provide, or third parties may provide, links to non-JavaScriptBank.com Internet World Wide Web sites or resources. Because JavaScriptBank.com has no control over such sites and resources, you acknowledge and agree that JavaScriptBank.com is not responsible for the availability of such external sites or resources, and does not endorse and is not responsible or liable for any content, advertising, products, or other materials on or available from such sites or resources. You further acknowledge and agree that JavaScriptBank.com shall not be responsible or liable, directly or indirectly, for any damage or loss caused or alleged to be caused by or in connection with use of or reliance on any such content, goods or services available on or through any such site or resource.