将输入插入两个或多个表

时间:2014-08-02 23:02:04

标签: php mysql laravel

我有一个来自它,它有一个动态表输入字段和其他一个或多个输入。当我提交上面的内容时,我已经解释了我想从动态表中插入一个表,并且我想将其他输入结果插入到另一个表中。我该怎么办呢?请在下面看我的代码。

<html>
<head>
    <title>Create</title>
    {{ HTML::style('css/bootstrap.3.0.0.css') }}
    <script src="/js/jquery-1.7.1.js"></script>

    <script type="text/javascript">
        var current_counter = 0;

        $(document).ready(function() {
            // When User Click And New Row
            $('#add-new-row').on('click',function(){
                current_counter ++;
                var newrow = $('<tr><td><input type="text" name="product[0]qty[' + current_counter +']"></td><td><input type="text" name="product[0]item[' + current_counter +']"></td><td><input type="text" name="product[0]amount[' + current_counter +']"></td></tr>');
                $('#row_container').append(newrow);
            });         
        });
    </script>
</head>
<body>
    <div class="container">
        <div class="row">
            <div class="col-md-12">
                <h1>Add New Order</h1>
            </div>
        </div>

        <div class="row">
            <div class="col-md-12 col-md-offset-10">
                <button type="button" class="btn btn-primary" id="add-new-row">Add New Row</button>
            </div>
            <hr>
            <div class="col-md-12">
                {{ Form::open(array('url' => '/create', 'role' => 'form')) }}

                    <table class="table table-bordered">
                        <thead>
                            <tr>
                              <th><h4>QTY</h4></th>
                              <th><h4>ITEM</h4></th>
                              <th><h4>Amount</h4></th>
                            </tr>
                        </thead>

                        <tbody id='row_container'>

                        </tbody>
                    </table>    

                    <div class="form-group">
                        <label for="discount">Discount</label>
                        <input type="text" class="form-control" name="discount" id="discount" placeholder="Discount">
                    </div>

                    <button type="submit" class="btn btn-primary">Submit</button>
                    <a href="{{ URL::to('/')}}"><button type="button" class="btn btn-danger">Cancel</button></a>

                {{ Form::close() }}
            </div>
        </div>
    </div>
</body>
</html>

0 个答案:

没有答案