数据未使用jquery发布到cgi脚本

时间:2015-06-08 08:47:21

标签: javascript jquery html perl cgi

jQuery用于动态添加多个字段。如果我提交表单,在params中只存在静态字段数据(即那些不是使用jQuery创建的数据)。在参数中没有看到jQuery附加字段创建的数据。

如需更多说明,请查看以下链接:http://jsfiddle.net/15zjsbn1/5/

如果我用一些html路径删除launcher.cgi,那么它的工作正常,所有的值都会被发布。

所以我认为问题在于cgi脚本

<h2>
    <a href="#" id="addScnt">Add Another Input Box</a>
</h2>

<FORM name="frmMr" action="launcher.cgi" method="POST">
    <div id="p_scents">
        <p>
            <label for="p_scnts1"> <select  id="p_scnt1"  name="p_scnt1_0">
                <option value="ak">ak</option>
                <option value="ac">ac</option>
                </select> 
            </label>

            <label for="p_scnts2"><select  id="p_scnt2" name="p_scnt2_0">                     
                 <option value="1">1</option>
                 <option value="2">2</option>
                 </select>
             </label>

            <label for="p_scnts3">
                <input type="text" id="p_scnt3" size="20" name="p_scnt3_0" value="" placeholder="Category" />
            </label>

            &nbsp &nbsp &nbsp

            <label for="p_scnts4">
                <input type="text" id="p_scnt4" size="20" name="p_scnt4_0" value="" placeholder="Message" />
            </label>

            &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp

            <label for="p_scnts5">
                <input type="checkbox" id="p_scnt5" name="p_scnt5_0" value=1 >
                Mail 
            </label><br/>
        </p>
    </div><br>

    <input type="submit" value="submit" href="xxx" >
    <input type="button" id="addScnt" value="hi" />
</FORM>
$(function() {
    var scntDiv = $('#p_scents');
    var i = $('#p_scents p').size() + 1;

    $('#addScnt').live('click', function() {
        $('<p><label for="p_scnts1"><select  id="p_scnt1"  name="p_scnt1_'+ i +'" ><option value="akshayt">akshayt</option>                        <option value="acatherine">acatherine</option></select></label><label for="p_scnts2"><select  id="p_scnt2" name="p_scnt2_' + i +'"> <option value="1">1</option>               <option value="2">2</option></select></label><label for="p_scnts3"><input type="text" id="p_scnt3" size="20" name="p_scnt3_' + i +'" value="" placeholder="Category" /></label> &nbsp &nbsp &nbsp &nbsp<label for="p_scnts4"><input type="text" id="p_scnt4" size="20" name="p_scnt4_' + i +'" value="" placeholder="Message" /></label> <label for="p_scnts5"><input type="checkbox" id="p_scnt5" name="p_scnt5_'+ i +'" value=1 >Mail </label> &nbsp &nbsp &nbsp &nbsp<a href="#" id="remScnt">Remove</a></p>').appendTo(scntDiv);

        i++;
        return false;
    });

    $('#remScnt').live('click', function() {
        if (i > 2) {
            $(this).parents('p').remove();
            i--;
        }
        return false;
    });
});
#!/usr/bin/perl
print "Content-type: text/plain\n\n";
use CGI;
use DBI;
use CGI::Carp qw(fatalsToBrowser);

$db = "chat";
$host = "xxx";
$user = 'xxx';
$password  = 'xxx';
$dbh = DBI->connect("DBI:mysql:database=$db",$user,$password)  or die         $DBI::errstr;
my $cgi = CGI->new;
my @key = $cgi->param;
print @key;

## it prints p_scnt1_0 p_scnt2_0 p_scnt3_0 p_scnt4_0 

0 个答案:

没有答案