我有这些领域。我想动态添加这组相同的字段。我可以一次做一个,但似乎无法重复所有字段。我正在建立一个内部采购订单和库存管理系统,这是最后一部分缺失。任何帮助将不胜感激。
<script type='text/javascript'>//<![CDATA[
$(function(){
$('.multi-field-wrapper').each(function() {
var $wrapper = $('.multi-fields', this);
$(".add-field", $(this)).click(function(e) {
$('.multi-field:first-child',
$wrapper).clone(true) .appendTo($wrapper).find
('input').val('').focus();
});
$('.multi-field .remove-field', $wrapper).click(function() {
if ($('.multi-field', $wrapper).length > 1)
$(this).parent('.multi-field').remove();
});
});
});//]]>
</script>
<form role="form" action="test2.php" method="POST">
<label>Stuff</label>
<div class="multi-field-wrapper">
<div class="multi-fields">
<div class="multi-field">
<?php mysql_connect("localhost", "root", "deadman1") or
die("Connection Failed"); mysql_select_db("inv")or
die("Connection Failed"); $query = "SELECT * FROM po order by id
desc limit 1"; $result = mysql_query($query); ?>
<select name="po">
<?php while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { ?>
<option value="<?php echo $line['ID'];?>
"> <?php echo $line['ID'];?>
</option> <?php } ?>
</select>
<input type="text" name="vendor">
<input type="text" name="part">
<input type="text" name="qty">
<input type="text" name="min">
<button type="button" class="remove-field">Remove</button>
</div>
</div>
<button type="button" class="add-field">Add field</button>
<br>
<br>
<br>
<center><input type="submit" name="submit" value="PURCHASE">
</center>
</div>
</form>