Subscribe Us

HTML & Javascript

 





Four Arithmetic Operation with the help of HTML & Javascript 


<!DOCTYPE html>

<html>

<head>

<title>Four function calculators</title>

<script language="javascript">

function Addition()

 {

  var x,y,c,c1,z,sp, c2,c3;

  x=parseInt(document.calculator.x.value);

  y=parseInt(document.calculator.y.value);

  c=document.getElementById("c");

  c1=document.getElementById("c1");

  sp=document.getElementById("sp");

  c2=document.getElementById("c2");

  c3=document.getElementById("c3");

  if(c.checked==true)

  {

  z=x+y;

  //alert(z);

  sp.innerHTML=z;

  c1.checked=false;

  c2.checked=false;

  c3.checked=false;

  }


// body...

}

function Substraction()

 {

  var x,y,c,c1,z,sp,c2,c3;

  x=parseInt(document.calculator.x.value);

  y=parseInt(document.calculator.y.value);

  c=document.getElementById("c");

  c1=document.getElementById("c1");

  sp=document.getElementById("sp");

  c2=document.getElementById("c2");

  c3=document.getElementById("c3");

  if(c1.checked==true)

  {

  z=x-y;

  //alert(z);

  sp.innerHTML=z;

  c.checked=false;

  c2.checked=false;

  c3.checked=false;



  }


// body...

}

function multiplication()

{

var x,y,c,c1,z,sp,c2,c3;

x=parseInt(document.calculator.x.value);

y=parseInt(document.calculator.y.value);

c=document.getElementById("c");

c1=document.getElementById("c1");

sp=document.getElementById("sp");

c2=document.getElementById("c2");

  c3=document.getElementById("c3");

if (c2.checked==true) 

{

z=x*y;

//alert(z);

sp.innerHTML=z;

c.checked=false;

c1.checked=false;

c3.checked=false;

}

}

function division()

{

var x,y,c,c1,z,sp,c2,c3;

x=parseInt(document.calculator.x.value);

y=parseInt(document.calculator.y.value);

c=document.getElementById("c");

c1=document.getElementById("c1");

sp=document.getElementById("sp");

c2=document.getElementById("c2");

  c3=document.getElementById("c3");

if (c3.checked==true) 

{

z=x/y;

//alert(z);

sp.innerHTML=z;

c.checked=false;

c1.checked=false;

c2.checked=false;

}

}

</script>

</head>

<body>

<form name="calculator">

Enter first Number<input type="text" name="x"><br>

Enter second number<input type="text" name="y"><br>

Answer:<span id="sp"></span>

<input type="checkbox" name="c" id="c" value="add" onclick="Addition();">Add

<input type="checkbox" name="c1" id="c1" value="sub" onclick="Substraction();">Sub

<input type="checkbox" name="c2" id="c2" value="multiplication" onclick="multiplication();">multi

<input type="checkbox" name="c3" id="c3" value="division" onclick="division();">div


</body>

</html>

Share:

0 Comments:

Post a Comment

If you have any doubts . Please let me know.

Powered by Blogger.

Ad Code

Responsive Advertisement

Ad Code

Responsive Advertisement

Featured post

Search This Blog

Recently added book names

THE HTML AND CSS WORKSHOP   | MICROSOFT POWER BI COOKBOOK   | MongoDB in Action, 2nd Edition  | ADVANCED DEEP LEARNING WITH PYTHON   | Cracking Codes with Python An Introduction to Building and Breaking  | Moris Mano Degital Design 3rd Edition  | Beginning App Development with Flutter by Rap Payne  |react hooks in Action - John Larsen   | Artificial Intelligence A Modern Approach Third Edition Stuart Russel  | Data Structures and Algorithms - Narasimha Karumanchi   | Thomas S.M. - PostgreSQL High Availability Cookbook - 2017  | Gunnard Engebreth PHP 8 Revealed Use Attributes the JIT Compiler   | ICSE Class X Computer Application Notes   | INTERNET OF THINGS PROJECTS WITH ESP32   | 100 aptitude trick(102pgs)s   | OBJECT_ORIENTED_PROGRAMMING Question & Answer   | C questions and answer   | Full_Book_Python_Data_Structures_And_Algorithm   | Jira 8 Administration Cookbook Third Edition  | KALI LINUX WIRELESS PENETRATION TESTING BEGINNERS GUIDE THIRD EDITION - Cameron Buchanan, Vivek Ramachandran  HTML5 & javascript By :- Jeanine Meyer   | Python For Beginners Ride The Wave Of Artificial Intelligence   | HackingTheXbox   | Introduction to Algorithms 3rd.Edition - (CLRS)   | The C++ Programming Language - Bjarne Stroustrup   | Modern C++ Programming Cookbook - Marius Bancila   | Java The Complete Reference Eleventh Edition   Data_Communications and Networking 4th Ed Behrouz A Forouzan   | DevOps with Kubernetes - Hideto Saito   | The-Linux-Command-Line-A-Complete-Introduction   | Assembly Language for X86 Processors KIP R. Irvine   | Effective_Modern_C++ - Scott Meyer

Contact Form

Name

Email *

Message *

Followers

Mobile Logo Settings

Mobile Logo Settings
image

Computer Training School Regd. under Govt. of West Bengal Society Act 1961

Header Ads Widget

Responsive Advertisement

Hot Widget

random/hot-posts

Recent in Sports

Popular Posts

Labels

Blog Archive

Blogger templates