javascript变量转移到php

时间:2012-10-23 13:48:34

标签: php javascript transfer

这是我的代码

的javascript:

<script type="text/javascript">
$(function() {
    var scntDiv = $('.create');
    var i = $('.create table').size() + 1;
    $('.add').live('click', function() {
            $('<table><tr><td><input type="text" name="item' + i +'" id="textbox_input" placeholder="Item" /></td><td> <input type="number" name="qtty'+ i + '" id="textbox_number" placeholder="Qtty'+i+'"/></td><td><button type="button" class="remove" id="button">Remove</button></td></tr></table>').appendTo(scntDiv);
            i++;
var number = i;
            return false;
    });
    $('.remove').live('click', function() { 
            if( i > 1 ) {
                    $(this).parents('table').remove();
                    i--;
            }
            return false;
    });
}
});
 </script>

html的:

<div class="create" style=" padding:10px; width:450px; -moz-border-radius:10px;-webkit-    border-radius:10px; top:10px; left:10px; height:540px; background-color:#FFF; position:absolute; overflow:scroll;">

<form method="POST" action="create.php">
<table>
<tr>
<td><input type="text" name="title" id="textbox_input" placeholder="Title"/></td>
<td></td>
<td><input type="submit" value="Save" class="save" id="button" /></td>
</tr>
<tr>
<td><input type="text" name="item1" id="textbox_input" placeholder="Item"/></td>
<td><input type="number" name="qtty1" id="textbox_number" placeholder="Qtty"/></td>
<td><button type="button" class="add" id="button">Add</button></td>
</tr>
</table>
</form>
</div>

我需要将var号传递给create.php。表单是为用户创建清单。当他们点击添加按钮时,项目和数量字段将添加。并且当单击添加按钮时,var i将增加1,var编号将保存最后一个var i。问题是如何将var number传递给create.php?

0 个答案:

没有答案