Duplicate Form using button











up vote
-4
down vote

favorite












I'm trying to duplicate 4 input text. For example I want to duplicate 'Produk Simpanan Saham', then only 4 input on 'Produk Simpanan Saham' div will be duplicated. I already tried a few methods using jQuery but it seem doesn't work.



<form action="" method="post" class="form-horizontal">
<br><br>
<div class="form-group">
Upload File :
<input type="file" name="file">
</div>
<div class="saham">
<div class="w3-container w3-black">
<h3>
<center>Produk Simpanan Saham</center>
</h3>
</div>
<label for="kp_produk">Kode Produk :</label>
<input type="text" name="kp_produk" class="form-control">
<br>
<label for="produk_saham">Produk :</label>
<input type="text" name="produk_saham" class="form-control">
<br>
<label for="bunga_saham">Bunga :</label>
<input type="text" name="bunga_saham" class="form-control">
<br>
<label for="ket_saham">Keterangan :</label>
<input type="text" name="ket_saham" class="form-control">
</div>
<div class="harian">
<div class="w3-container w3-black">
<h3>
<center>Produk Simpanan Harian</center>
</h3>
</div>
<label for="kp_harian">Kode Produk :</label>
<input type="text" name="kp_harian" class="form-control">
<br>
<label for="produk_harian">Produk :</label>
<input type="text" name="produk_harian" class="form-control">
<br>
<label for="bunga_harian">Bunga :</label>
<input type="text" name="bunga_harian" class="form-control">
<br>
<label for="ket_harian">Keterangan :</label>
<input type="text" name="ket_harian" class="form-control">
</div>









share|improve this question




















  • 2




    clone() sounds like what you need to use. It's impossible to say why your code isn't working without seeing it
    – Rory McCrossan
    Nov 7 at 9:19















up vote
-4
down vote

favorite












I'm trying to duplicate 4 input text. For example I want to duplicate 'Produk Simpanan Saham', then only 4 input on 'Produk Simpanan Saham' div will be duplicated. I already tried a few methods using jQuery but it seem doesn't work.



<form action="" method="post" class="form-horizontal">
<br><br>
<div class="form-group">
Upload File :
<input type="file" name="file">
</div>
<div class="saham">
<div class="w3-container w3-black">
<h3>
<center>Produk Simpanan Saham</center>
</h3>
</div>
<label for="kp_produk">Kode Produk :</label>
<input type="text" name="kp_produk" class="form-control">
<br>
<label for="produk_saham">Produk :</label>
<input type="text" name="produk_saham" class="form-control">
<br>
<label for="bunga_saham">Bunga :</label>
<input type="text" name="bunga_saham" class="form-control">
<br>
<label for="ket_saham">Keterangan :</label>
<input type="text" name="ket_saham" class="form-control">
</div>
<div class="harian">
<div class="w3-container w3-black">
<h3>
<center>Produk Simpanan Harian</center>
</h3>
</div>
<label for="kp_harian">Kode Produk :</label>
<input type="text" name="kp_harian" class="form-control">
<br>
<label for="produk_harian">Produk :</label>
<input type="text" name="produk_harian" class="form-control">
<br>
<label for="bunga_harian">Bunga :</label>
<input type="text" name="bunga_harian" class="form-control">
<br>
<label for="ket_harian">Keterangan :</label>
<input type="text" name="ket_harian" class="form-control">
</div>









share|improve this question




















  • 2




    clone() sounds like what you need to use. It's impossible to say why your code isn't working without seeing it
    – Rory McCrossan
    Nov 7 at 9:19













up vote
-4
down vote

favorite









up vote
-4
down vote

favorite











I'm trying to duplicate 4 input text. For example I want to duplicate 'Produk Simpanan Saham', then only 4 input on 'Produk Simpanan Saham' div will be duplicated. I already tried a few methods using jQuery but it seem doesn't work.



<form action="" method="post" class="form-horizontal">
<br><br>
<div class="form-group">
Upload File :
<input type="file" name="file">
</div>
<div class="saham">
<div class="w3-container w3-black">
<h3>
<center>Produk Simpanan Saham</center>
</h3>
</div>
<label for="kp_produk">Kode Produk :</label>
<input type="text" name="kp_produk" class="form-control">
<br>
<label for="produk_saham">Produk :</label>
<input type="text" name="produk_saham" class="form-control">
<br>
<label for="bunga_saham">Bunga :</label>
<input type="text" name="bunga_saham" class="form-control">
<br>
<label for="ket_saham">Keterangan :</label>
<input type="text" name="ket_saham" class="form-control">
</div>
<div class="harian">
<div class="w3-container w3-black">
<h3>
<center>Produk Simpanan Harian</center>
</h3>
</div>
<label for="kp_harian">Kode Produk :</label>
<input type="text" name="kp_harian" class="form-control">
<br>
<label for="produk_harian">Produk :</label>
<input type="text" name="produk_harian" class="form-control">
<br>
<label for="bunga_harian">Bunga :</label>
<input type="text" name="bunga_harian" class="form-control">
<br>
<label for="ket_harian">Keterangan :</label>
<input type="text" name="ket_harian" class="form-control">
</div>









share|improve this question















I'm trying to duplicate 4 input text. For example I want to duplicate 'Produk Simpanan Saham', then only 4 input on 'Produk Simpanan Saham' div will be duplicated. I already tried a few methods using jQuery but it seem doesn't work.



<form action="" method="post" class="form-horizontal">
<br><br>
<div class="form-group">
Upload File :
<input type="file" name="file">
</div>
<div class="saham">
<div class="w3-container w3-black">
<h3>
<center>Produk Simpanan Saham</center>
</h3>
</div>
<label for="kp_produk">Kode Produk :</label>
<input type="text" name="kp_produk" class="form-control">
<br>
<label for="produk_saham">Produk :</label>
<input type="text" name="produk_saham" class="form-control">
<br>
<label for="bunga_saham">Bunga :</label>
<input type="text" name="bunga_saham" class="form-control">
<br>
<label for="ket_saham">Keterangan :</label>
<input type="text" name="ket_saham" class="form-control">
</div>
<div class="harian">
<div class="w3-container w3-black">
<h3>
<center>Produk Simpanan Harian</center>
</h3>
</div>
<label for="kp_harian">Kode Produk :</label>
<input type="text" name="kp_harian" class="form-control">
<br>
<label for="produk_harian">Produk :</label>
<input type="text" name="produk_harian" class="form-control">
<br>
<label for="bunga_harian">Bunga :</label>
<input type="text" name="bunga_harian" class="form-control">
<br>
<label for="ket_harian">Keterangan :</label>
<input type="text" name="ket_harian" class="form-control">
</div>






php jquery






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 7 at 9:19









Rory McCrossan

238k29200243




238k29200243










asked Nov 7 at 9:17









InFocus

126




126








  • 2




    clone() sounds like what you need to use. It's impossible to say why your code isn't working without seeing it
    – Rory McCrossan
    Nov 7 at 9:19














  • 2




    clone() sounds like what you need to use. It's impossible to say why your code isn't working without seeing it
    – Rory McCrossan
    Nov 7 at 9:19








2




2




clone() sounds like what you need to use. It's impossible to say why your code isn't working without seeing it
– Rory McCrossan
Nov 7 at 9:19




clone() sounds like what you need to use. It's impossible to say why your code isn't working without seeing it
– Rory McCrossan
Nov 7 at 9:19












1 Answer
1






active

oldest

votes

















up vote
0
down vote













you mush have blueprint of field first like



var blueprint= '<div class="saham">'+
'<div class="w3-container w3-black">'+
'<h3>'+
'<center>Produk Simpanan Saham</center>'+
'</h3>'+
'</div>'+
'<label for="kp_produk">Kode Produk :</label>'+
'<input type="text" name="kp_produk" class="form-control">'+
'<br>'+
......


used for all name field to get array request when you send form to server
example :



 '<input type="text" name="kp_produk" class="form-control">'+


and make button add like (jquery) example



<button onclick="$('form').append(blueprint)">add</button>





share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














     

    draft saved


    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53186474%2fduplicate-form-using-button%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote













    you mush have blueprint of field first like



    var blueprint= '<div class="saham">'+
    '<div class="w3-container w3-black">'+
    '<h3>'+
    '<center>Produk Simpanan Saham</center>'+
    '</h3>'+
    '</div>'+
    '<label for="kp_produk">Kode Produk :</label>'+
    '<input type="text" name="kp_produk" class="form-control">'+
    '<br>'+
    ......


    used for all name field to get array request when you send form to server
    example :



     '<input type="text" name="kp_produk" class="form-control">'+


    and make button add like (jquery) example



    <button onclick="$('form').append(blueprint)">add</button>





    share|improve this answer

























      up vote
      0
      down vote













      you mush have blueprint of field first like



      var blueprint= '<div class="saham">'+
      '<div class="w3-container w3-black">'+
      '<h3>'+
      '<center>Produk Simpanan Saham</center>'+
      '</h3>'+
      '</div>'+
      '<label for="kp_produk">Kode Produk :</label>'+
      '<input type="text" name="kp_produk" class="form-control">'+
      '<br>'+
      ......


      used for all name field to get array request when you send form to server
      example :



       '<input type="text" name="kp_produk" class="form-control">'+


      and make button add like (jquery) example



      <button onclick="$('form').append(blueprint)">add</button>





      share|improve this answer























        up vote
        0
        down vote










        up vote
        0
        down vote









        you mush have blueprint of field first like



        var blueprint= '<div class="saham">'+
        '<div class="w3-container w3-black">'+
        '<h3>'+
        '<center>Produk Simpanan Saham</center>'+
        '</h3>'+
        '</div>'+
        '<label for="kp_produk">Kode Produk :</label>'+
        '<input type="text" name="kp_produk" class="form-control">'+
        '<br>'+
        ......


        used for all name field to get array request when you send form to server
        example :



         '<input type="text" name="kp_produk" class="form-control">'+


        and make button add like (jquery) example



        <button onclick="$('form').append(blueprint)">add</button>





        share|improve this answer












        you mush have blueprint of field first like



        var blueprint= '<div class="saham">'+
        '<div class="w3-container w3-black">'+
        '<h3>'+
        '<center>Produk Simpanan Saham</center>'+
        '</h3>'+
        '</div>'+
        '<label for="kp_produk">Kode Produk :</label>'+
        '<input type="text" name="kp_produk" class="form-control">'+
        '<br>'+
        ......


        used for all name field to get array request when you send form to server
        example :



         '<input type="text" name="kp_produk" class="form-control">'+


        and make button add like (jquery) example



        <button onclick="$('form').append(blueprint)">add</button>






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 7 at 10:28









        yuanganteng

        192




        192






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53186474%2fduplicate-form-using-button%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            這個網誌中的熱門文章

            Xamarin.form Move up view when keyboard appear

            Post-Redirect-Get with Spring WebFlux and Thymeleaf

            Anylogic : not able to use stopDelay()