SHARE
TWEET

Untitled

a guest Nov 13th, 2019 84 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <html>
  2.   <head>
  3.     <title>Form submit with nodejs</title>
  4.   </head>
  5.   <body>
  6.         <form id="uploadForm"  enctype="multipart/form-data"  action="/myform" method="get">
  7.             <input type="text" name="mytext1"> +
  8.             <input type="text" name="mytext2">
  9.             <input type="submit" value="Jumlahkan" name="submit"><br><hr>
  10.             <span id = "status"></span>
  11.         </form>
  12.         <form id="uploadForm"  enctype="multipart/form-data"  action="/myformkurang" method="get">
  13.  
  14.             <input type="text" name="mytext1"> +
  15.             <input type="text" name="mytext2">
  16.             <input type="submit" value="Kurangkan" name="submit"><br><hr>
  17.             <span id = "status"></span>
  18.         </form>
  19.         <form id="uploadForm"  enctype="multipart/form-data"  action="/myformkali" method="get">
  20.  
  21.             <input type="text" name="mytext1"> +
  22.             <input type="text" name="mytext2">
  23.             <input type="submit" value="Kali" name="submit"><br><hr>
  24.             <span id = "status"></span>
  25.         </form>
  26.         <form id="uploadForm"  enctype="multipart/form-data"  action="/myformbagi" method="get">
  27.  
  28.             <input type="text" name="mytext1"> +
  29.             <input type="text" name="mytext2">
  30.             <input type="submit" value="Bagi" name="submit"><br><hr>
  31.             <span id = "status"></span>
  32.         </form>
  33.         <form id="uploadForm"  enctype="multipart/form-data"  action="/myformmatrix" method="get">
  34.             <input type="text" name="a1">
  35.             <input type="text" name="b1">
  36.             <input type="text" name="c1"> +
  37.             <input type="text" name="a2">
  38.             <input type="text" name="b2">
  39.             <input type="text" name="c2"><br>
  40.             <input type="text" name="d1">
  41.             <input type="text" name="e1">
  42.             <input type="text" name="f1"> +
  43.             <input type="text" name="d2">
  44.             <input type="text" name="e2">
  45.             <input type="text" name="f2"><br>
  46.             <input type="text" name="g1">
  47.             <input type="text" name="h1">
  48.             <input type="text" name="i1"> +
  49.             <input type="text" name="g2">
  50.             <input type="text" name="h2">
  51.             <input type="text" name="i2"><br>
  52.             <input type="submit" value="Jumlahkan" name="submit"><br><hr>
  53.             <span id = "status"></span>
  54.         </form>
  55.   </body>
  56.  
  57. </html>
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74. var express = require('express');
  75. var app = express();
  76. app.get('/myform', function(req, res){
  77.     var b1 = req.query.mytext1;
  78.     var b2 = req.query.mytext2;
  79.     res.send('Hasil Penjumlahannya:' +parseInt(parseInt(b1)+parseInt(b2)));
  80. });
  81.  
  82. app.get('/myformkurang', function(req, res){
  83.     var b1 = req.query.mytext1;
  84.     var b2 = req.query.mytext2;
  85.     res.send('Hasil Penjumlahannya:' +parseInt(parseInt(b1)-parseInt(b2)));
  86. });
  87.  
  88. app.get('/myformkali', function(req, res){
  89.     var b1 = req.query.mytext1;
  90.     var b2 = req.query.mytext2;
  91.     res.send('Hasil Penjumlahannya:' +parseInt(parseInt(b1)*parseInt(b2)));
  92. });
  93.  
  94. app.get('/myformbagi', function(req, res){
  95.     var b1 = req.query.mytext1;
  96.     var b2 = req.query.mytext2;
  97.     res.send('Hasil Penjumlahannya:' +parseFloat(parseFloat(b1)/parseFloat(b2)));
  98. });
  99.  
  100. app.get('/myformmatrix', function(req, res){
  101.     var a1 = req.query.a1;
  102.     var a2 = req.query.a2;
  103.     var b1 = req.query.b1;
  104.     var b2 = req.query.b2;
  105.     var c1 = req.query.c1;
  106.     var c2 = req.query.c2;
  107.     var d1 = req.query.d1;
  108.     var d2 = req.query.d2;
  109.     var e1 = req.query.e1;
  110.     var e2 = req.query.e2;
  111.     var f1 = req.query.f1;
  112.     var f2 = req.query.f2;
  113.     var g1 = req.query.g1;
  114.     var g2 = req.query.g2;
  115.     var h1 = req.query.h1;
  116.     var h2 = req.query.h2;
  117.     var i1 = req.query.i1;
  118.     var i2 = req.query.i2;
  119.     res.send('Hasil Penjumlahannya:' +'<br>' +parseInt(parseInt(a1)+parseInt(a2)) +' ' + +parseInt(parseInt(b1)+parseInt(b2)) + +parseInt(parseInt(c1)+parseInt(c2)));
  120. });
  121.  
  122. app.get('/',function(req,res){
  123.       res.sendFile(__dirname + "/index.html");
  124. });
  125.  
  126. app.listen(3000,function(){
  127.     console.log("App listening on port: 3000");
  128. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top