0

I have a script

<html>
<head>
<title> FORM REGISTRASI </title>
<link rel="stylesheet" type="text/css" href="css/coba.css">
</head>
<body>
<script type="text/javascript" src="js/default.js"></script>
<!--Input-->
<form name="fform" class="daftar">
<h1>REGISTRASI AKUN</h1>
<fieldset class="row1">
    <legend>Emal</legend>
    <p>
        <label>Email</label><input type="text" placeholder="Email" name="email">
        <label>Password</label><input type="password" placeholder="Password">
    </p>
    <p>
        <label>Konfirmasi Email</label><input type="text" placeholder="Konfirmasi Email">
        <label>Konfirmasi Password</label><input type="password" placeholder="Konfirmasi Password">
    </p>
</fieldset>
<fieldset class="row2">
    <legend>Biodata Pengguna</legend>
    <p>
        <label>Nama Lengkap</label><input type="text" class="panjang" placeholder="Nama Lengkap" name="nama">
    </p>
    <p>
        <label>Nomor Telepon</label><input type="text" maxlength="12" name="telepon">
    </p>
    <p>
        <label> Alamat </label>
        <textarea cols="32" rows="5" placeholder="Alamat" name="alamat"></textarea>
    </p>
</fieldset>
<fieldset class="row3">
    <legend>Biodata Lain</legend>
    <p>
    <label>Jenis Kelamin</label>
    <input type="radio" value="Pria" name="Pria">
    <label class="JK">Pria</label>
    <input type="radio" value="Wanita" name="Wanita">
    <label class="JK">Wanita</label>
    </p>
    <p>
    <label>Tempat Lahir</label>
    <input class="panjangkota" type="text" maxlength="20" name="tempatlahir" />
    </p>
    <p>
    <label>Tanggal Lahir</label>
    <input type="date" size="2" maxlength="2" name="tanggal" />
    </p>
    <p>
        <label>Hobby</label>
        <input type="checkbox" value="Browsing" name="Browsing">
        <label class="hobby">Browsing</label>
        <input type="checkbox" value="Membaca" name="Membaca">
        <label class="hobby">Membaca</label>
    </p>
    <p>
        <label> </label>    
        <input type="checkbox" value="Sepakbola" name="Sepakbola">
        <label class="hobby">Sepakbola</label>
        <input type="checkbox" value="Galau" name="Galau">
        <label class="hobby">Galau</label>
    </p>
</fieldset>
<div><input type="button" value="kirim" onclick="daftar()"></div>
<tr>
<div><input type="reset" value="ulang"></div>
</form>
<!--Output-->
<hr>
<form class="daftar2">
<h1>OUTPUT</h1>
<fieldset class="row4">
    <legend>Pendaftaran Akun</legend>
    <p>
        <label>Nama Depan :</label><input type="text" name="znama">
    </p>
    <p>
        <label>Nomor Telepon :</label><input type="text" name="ztelepon">
    </p>
    <p> 
        <label>Email :</label><input type="text" name="zemail">
    </p>
    <p> 
        <label>Jenis Kelamin :</label><input type="text" name="zJK">
    </p>
    <p> 
        <label>Tempat Lahir :</label><input type="text" name="ztempatlahir">
    </p>
    <p> 
        <label>Tanggal Lahir :</label><input type="text">
    </p>
    <p> 
        <label>Hobby :</label><input type="text" name="zHobby">
    </p>
    <p> 
        <label>Alamat :</label><textarea cols="32" rows="5" zalamat></textarea>
    </p>
</fieldset> 
</form>
</body>
</html>

and I have a JavaScript code link this:

function daftar()
{
var emailstr = (document.fform.email.value);
var namastr  = (document.fform.nama.value);
var teleponstr = (document.fform.telepon.value);
var alamatstr = (document.fform.alamat.value);
var tempatlahirstr = (document.fform.tempatlahir.value);

//obejek teks
(document.fform.zemail.value) = emailstr;
(document.fform.znama.value) = namastr;
(document.fform.ztelepon.value) = teleponstr;
(document.fform.ztempatlahir.value) = tempatlahirstr;

//textarea
(document.fform.zalamat.value) = alamatstr;

//radio button
if (fform.Pria.checked) 
{
    Pria = (document.fform.Pria.value);
    (document.fform.zJK.value) = Pria;
} else
if (fform.Wanita.checked) 
{
    Wanita = (document.fform.Wanita.value);
    (document.fform.zJK.value) = Wanita;
}

//checkbox

if (fform.Browsing.checked)
{
    Browsing = (document.fform.Browsing.value);
    (document.fform.zHobby.value) = Browsing;
} else
if (fform.Membaca.checked)
{
    Membaca = (document.fform.Membaca.value);
    (document.fform.zHobby.value) = Membaca;
} else
if (fform.Sepakbola.checked) 
{
    Sepakbola = (document.fform.Sepakbola.value);
    (document.fform.zHobby.value) = Sepakbola;
} else
if (fform.Galau.checked) 
{
    Galau = (document.fform.Galau.value);
    (document.fform.zHobby.value) = Galau;
}

I want to print all item (specially for text and radio/checkbox object, don't see date object) in the input form to output form with one javascript function, when i try to submit all item, it didn't shown on output form. What wrong with that code and how to print all of them to the output form? Please help me, this is my collage assignment. (If you want, you can copy and paste that code to test that code).

1
  • try having a single input on each form, comment out everything else and go from there. No need to over complicate things before you have the basic button working. If you want answers, be very clear and specific about what your question is. We don't answer "what is wrong with my code" questions. Show that you've attempted the problem so we have a better idea of your thought process.
    – Observer
    Mar 27, 2016 at 5:13

1 Answer 1

0

For this pupose why dont you use angular js? its simple and easy bro.

<!DOCTYPE html>
<html>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<body>

<div ng-app="">

<p>Input something in the input box:</p>
Name:<input type="text" name="name" ng-model="name"><br>

<p>Gender: <input type="radio" ng-model="gen" value="male" name="gen">Male
<input type="radio" ng-model="gen" value="female" name="gen">Female</p>




<p ng-bind="name"></p>

<p ng-bind="gen"></p>

</div>

</body>
</html>

Learn more Angularjs from W3schools :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.