Javascript: Example of Addition, subtraction,multiply and divide in HTML
Example of javascript in HTML programming
<!DOCTYPE html>
<html> <head> <script type="text/javascript"> function add() { fst=parseInt(myform.fst.value); snd=parseInt(myform.snd.value); result=fst+snd; myform.result.value=result; } function subtract() { fst=parseInt(myform.fst.value); snd=parseInt(myform.snd.value); result=fst-snd; myform.result.value=result; } function multiply() { fst=parseInt(myform.fst.value); snd=parseInt(myform.snd.value); result=fst*snd; myform.result.value=result; } function dive() { fst=parseInt(myform.fst.value); snd=parseInt(myform.snd.value); result=fst/snd; myform.result.value=result; } </script> </head> <body> <Form name="myform"> <Table><tr> <Td>Input 1st number <Input type ="number" name="fst"><br><br></td> <Td>Input 2nd number <Input type ="number" name=snd><br><br></td> <Td><Input type="button" value="addition" onclick="add()"></Td> </Tr> <Tr><td colspan="1"></td><td><br> Output <Input type="number" name="result"><br><br><br></td> <Td><Input type="button" value="Subtraction" onclick="subtract()"> </Td></tr> <Tr><td colspan="1"> <Td> <Input type="button" value="Divide" onclick="dive()"></td> <Td> <Input type="button" value="Multiply" onclick="multiply()"></td> </Tr> </body> /html>
Output.
Too Good. Keep going ЁЯТР
ReplyDelete