Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>Operasi Hitung Aljabar</title>
- <link rel="stylesheet" type="text/css" href="<?php echo base_url()."assets/";?>style.css">
- </head>
- <body>
- <?php
- if(isset($_POST['hitung'])){
- $bil1 = $_POST['bil1'];
- $bil2 = $_POST['bil2'];
- $operasi = $_POST['operasi'];
- switch ($operasi) {
- case 'tambah':
- $hasil = $bil1+$bil2;
- break;
- case 'kurang':
- $hasil = $bil1-$bil2;
- break;
- case 'kali':
- $hasil = $bil1*$bil2;
- break;
- case 'bagi':
- $hasil = $bil1/$bil2;
- break;
- }
- }
- ?>
- <div class="kalkulator">
- <h2 class="judul">Operasi Hitung Aljabar</h2>
- <!-- <a class="brand" href="https://www.malasngoding.com">www.malasngoding.com</a> -->
- <form method="post" action="index.php">
- <input type="text" name="bil1" class="bil" autocomplete="off" placeholder="Masukkan Bilangan Pertama">
- <input type="text" name="bil2" class="bil" autocomplete="off" placeholder="Masukkan Bilangan Kedua">
- <select class="opt" name="operasi">
- <option value="tambah">+</option>
- <option value="kurang">-</option>
- <option value="kali">x</option>
- <option value="bagi">/</option>
- </select>
- <input type="submit" name="hitung" value="Hitung" class="tombol">
- </form>
- <?php if(isset($_POST['hitung'])){ ?>
- <input type="text" value="<?php echo $hasil; ?>" class="bil">
- <?php }else{ ?>
- <input type="text" value="0" class="bil">
- <?php } ?>
- </div>
- <script>
- function myFunction() {
- alert("Hello! I am an alert box!");
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement