Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <title>Belajar JAVASCRIPT</title>
- <link rel="stylesheet" href="css.css">
- <body>
- <main>
- <center><header>Javascript</header></center><hr>
- <script language = "javascript" src="js external.js"></script>
- </scri
- <hr>
- <form name="fdata">
- <pre>
- <center>
- Memasukkan Data Dengan Teks<br>
- Nama Lengkap :<input type = "text" name = "nama"/><br>
- Tempat Lahir :<input type = "text" name = "tempat"/><br>
- Tanggal Lahir :<input type = "text" name = "tanggal"/><br>
- Jenis Kelamin :<input type="radio" name="jkl" value="laki-laki">Laki-laki <input type="radio" name="jkp" value="perempuan">Perempuan
- Telp/Hp :<input type = "text" name = "telp"/><br>
- Alamat :<textarea name="alamat" rows=2 cols=20></textarea>
- </pre>
- <center>
- <input type = "button" value = "Send" onClick = "tekan()"/>
- <input type = "reset" value = "Reset">
- <hr width=800 color=#169f77>
- <pre>
- <center>
- Output<br>
- Nama :<input type = "text" name = "nama1"/><br>
- Tempat Lahir :<input type = "text" name = "tempat1"/><br>
- Tanggal Lahir :<input type = "text" name = "tanggal1"/><br>
- jenis Kelamin :<input type = "text" name="jenkel"><br>
- Telp/Hp :<input type = "text" name = "telp1"/><br>
- Alamat :<input type = "text" name = "alamat1" />
- </pre>
- </form>
- <script language="Javascript">
- function tekan(){
- var namastr= (document.fdata.nama.value);
- var tempatstr= (document.fdata.tempat.value);
- var tanggalstr= (document.fdata.tanggal.value);
- var telpstr= (document.fdata.telp.value);
- var alamatstr= (document.fdata.alamat.value);
- document.fdata.nama1.value= namastr;
- document.fdata.tempat1.value= tempatstr;
- document.fdata.tanggal1.value= tanggalstr;
- document.fdata.telp1.value= telpstr;
- document.fdata.alamat1.value= alamatstr;
- var jklstr= (document.fdata.jkl.value);
- var jkpstr= (document.fdata.jkp.value);
- if(document.fdata.jkl.checked==1)
- {
- if (document.fdata.jkp.checked==1)
- {
- document.fdata.jenkel.value=jklstr;
- document.fdata.jenkel.value=jkpstr;
- document.fdata.jenkel.value=0;
- alert('Anda Memilih 2 Jenis Kelamin coba lagi ya')
- }
- else
- {document.fdata.jenkel.value=jklstr}}
- else if(document.fdata.jkp.checked==1)
- {document.fdata.jenkel.value=jkpstr}
- else
- {alert('Anda Belum Memilih')}}
- </script>
- </main>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement