Thursday, 15 April 2010

jquery - perl cgi how to store/send data entered by user in dynamic table -



jquery - perl cgi how to store/send data entered by user in dynamic table -

after reading few threads forum , able create cgi page , dynamic table in it. need capture info entered in table , store in backend ( planning store db ).

can please show me how . heard can done using jquery , ajax. new web technology , stuck not knowing how proceed them.

note: mentioned dynamic table. user add/delete rows many wants. need capture data.

this have tried far

perl cgi script

#!c:\program files\perl\bin\perl utilize strict; utilize warnings; utilize cgi qw{ :standard }; utilize cgi::carp qw{ fatalstobrowser }; print_page_header(); print_html_head_section(); ################# ## subroutines ## ################# sub print_page_header { print "content-type: text/html\n\n"; } sub print_html_head_section { print "<head>\n"; print "<title>sample test page</title>\n"; print "<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js' type='text/javascript'></script>\n"; print "<script src='../js/mastertable_rowcontrol.js' type='text/javascript'></script>\n"; #print qq{ # <script> # function myfunction() { # var table=document.getelementbyid("master_table"); # (var i=1;i<table.rows.length;i++) { # alert(table.rows.[i].cells[0].innerhtml); # } # } # </script> # }; print "</head>\n"; } print qq{ <table id="master_table" border="0"> <tr> <th>col1</th> <th>col2</th> <th>col3</th> <th>col4</th> <td>&nbsp;</td> </tr> <tr> <td> <input type="text" name="col1" class="col1"/> </td> <td> <input type="text" name="col2" class="col2"/> </td> <td> <input type="text" name="col3" class="col3"/> </td> <td> <input type="text" name="col4" class="col4"/> </td> <td> <input type="button" name="addrow" class="add" value='add'/> </td> <td> <input type="button" name="removerow" class="removerow" value='delete'/> </td> </tr> <tr> <td colspan="4" align="center"> <input type="button" name="submit_data" class="submit" value="submit" onclick="myfunction()"/> </td> </tr> </table> };

jquery used create dynamic table

$(document).ready(function () { $(document).on('click','#master_table .add',function () { var row=$(this).closest('tr'); var clone = row.clone(); var tr= clone.closest('tr'); tr.find('input[type=text]').val(''); $(this).closest('tr').after(clone); var $span=$("#master_table tr"); $span.attr('id',function (index) { homecoming 'span' + index; }); }); $(document).on('click','#master_table .removerow',function () { if ($('#master_table .add').length > 1) { $(this).closest('tr').remove(); } }); });

it easier if built dynamic-table using html, , have submit user-input perl script farther processing or assorting, needed.

just design html form looks table (you can utilize of code have written). submit perl script, need this:

<form action="/somefolder/yourperlscript.pl" method="post"> <!-- table here --> </form>

you may remember, in linux location of file should begin "/somefolder/yourscript.pl" while on windows, should slash in origin "somefolder/yourscript.pl

jquery html ajax perl cgi

No comments:

Post a Comment