SHARE
TWEET

Untitled

Rofihimam Sep 11th, 2019 124 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.     <title>Interface dengan JS</title>
  5.     <link rel="stylesheet" type="text/css" href="interface.css">
  6.     <link href="https://fonts.googleapis.com/css?family=Bree+Serif&display=swap" rel="stylesheet">
  7. </head>
  8. <body>
  9.     <p id="coba">
  10.         <input class="tulis" type="text" name="nilai">
  11.         <input type="button" id="btnAmbilNilai" value="Ambil Nilai" onclick="ambilNilai();">
  12.         <input class="tulis" type="text" name="hasil">
  13.         <script type="text/javascript" language="javascript">
  14.             function ambilNilai() {
  15.                 //mengambil obyek input text pertama
  16.                 var obj1 = document.getElementsByTagName('input') [0];
  17.                 //mengambil obyek input button
  18.                 var obj2 = document.getElementsByTagName('input') [1];
  19.                 //mengambil obyek input text kedua
  20.                 var obj3 = document.getElementsByTagName('input') [2];
  21.                 //mengambil nilai input text pertama dan button
  22.                 var s1 = obj1.value;
  23.                 var s2 = obj2.value;
  24.                 //menampilkan nlai pada input text kedua
  25.                 obj3.value = s1 + " " + s2;
  26.             }
  27.         </script>
  28.     </p>
  29. </body>
  30. </html>
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
 
Top