0

这是我的代码

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 number 将保存最后一个 var i。问题是如何将 var 编号传输到 create.php?

4

0 回答 0