<! DOCTYPE html>functionAdd () {varA=parseint (document.getElementById ("NUM1"). Value);/*get the value of a*/ varB=parseint (document.getElementById ("num2"). Value); varC=parseint (document.getElementById ("num3"). Value=a+b);/*Value=a+b Pass the value of A+b to num3*///alert (a+b); } functionde () {varA=parseint (document.getElementById ("NUM1"). Value)/*get the value of a*/ varB=parseint (document.getElementById ("num2"). Value); varC=parseint (document.getElementById ("num3"). value=a-b); Alert (A-b); } functionMul () {/*in the method, click to start accessing the data*/ varA=parseint (document.getElementById ("NUM1"). Value);/*get the value of a*/ varB=parseint (document.getElementById ("num2"). Value); varC=parseint (document.getElementById ("num3"). value=a*b); Alert (A*b); } functionChu () {varA=parseint (document.getElementById ("NUM1"). Value);/*get the value of a*/ varB=parseint (document.getElementById ("num2"). Value); varC=parseint (document.getElementById ("num3"). value=a/b); Alert (A/b); } </script><! DOCTYPEHTML>
<HTMLxmlns="Http://www.w3.org/1999/html">
<Headlang="en">
<Metacharset="UTF-8">
<title></title>
<Script>
functionAdd(){
vara=parseint(Document.getElementById("NUM1").value);/ * Get the value of a */
varb=parseint(Document.getElementById("Num2").value);
varC=parseint(Document.getElementById("NUM3").value=a+b);/*value=a+b Pass the value of A+b to num3*/
Alert(a+b);
}
functionde(){
vara=parseint(Document.getElementById("NUM1").value)/ * Get the value of a */
varb=parseint(Document.getElementById("Num2").value);
varC=parseint(Document.getElementById("NUM3").value=a-b);
Alert(a-b);
}
functionMul(){/ * In the method, click to start accessing the data */
vara=parseint(Document.getElementById("NUM1").value);/ * Get the value of a */
varb=parseint(Document.getElementById("Num2").value);
varC=parseint(Document.getElementById("NUM3").value=a*b);
Alert(a*b);
}
functionChu(){
vara=parseint(Document.getElementById("NUM1").value);/ * Get the value of a */
varb=parseint(Document.getElementById("Num2").value);
varC=parseint(Document.getElementById("NUM3").value=a/b);
Alert(a/b);
}
</Script>
</Head>
<BR>
<label>Simple Calculator</label></BR>
<label>First Number:</label><inputtype="=text"id="NUM1"></BR>
<label>Second number:</label><inputtype="=text"id="Num2"></BR>
<Buttononclick="Add()">+</Button>
<Buttononclick="de()">-</Button>
<Buttononclick="Mul()">*</Button>
<Buttononclick="Chu()">/</Button><BR>
<label>Results:</label><inputtype="Text"id="NUM3">
</Body>
</HTML>
JS Write Simple Calculator