Rodel Barbin

Rodel Barbin

  • 1.6k
  • 108
  • 14.5k

Preview form field input array before submit

Aug 29 2023 2:05 AM

Hi Sir, Mam,

I would like to ask how can I preview the form fields like input text array, i.e text_name[] using jquery Dialog or any other

javascript function?. I used the code below AND IT ONLY DISPLAYS THE last record in array. I want to preview the data of a forms before submit to store records in database.

    for (var count = 0; count < input_array.length; count++) {
        var action_no = input_array[count];    
        var text_section1_target1_tab1 = '<table  class="table table-bordered" id="tab_section1">' +
                    '<thead class="thead-light">' +
                        '<tr>' +
                            '<th>No.</th>' +
                            '<th>A</th>' +
                            '<th>B</th>' +
                            '<th>C</th>' +
                            '<th>D</th>' +
                            '<th>REMARKS</th>' +
                        '</tr>' +
                    '</thead>' +
                    '<tbody id="tab_section1_tbody">' +
                    '<tr>' +
                        '<td>' + action_no.value + '</td>' +
                        '<td>Action1</td>' +
                        '<td>1</td>' +
                        '<td>1</td>' +
                        '<td>D</td>' +
                        '<td>OK</td>' +
                    '</tr>' +
                    '</tbody>' +
        '</table>';
    }

var data = text_section1_target1_tab1;
    
    $('#preview_data').html('');
    $('#preview_data').append(data);
    $('#preview_data').dialog({
        resizable: false,
        width:1000,
        height:1024,
        modal: true,
        buttons: {
            'Submit': function() {
                //submit the form
                $(this).dialog("close");
                return 0;
            },
            Cancel: function() {
                $(this).dialog("close");
                return 0;
            }
        }
    });   

 

Any help much appreciated.

 

Thank you.

 

Rodel


Answers (3)