#c输入带有@ html.ActionLink的mvc app形式的dinamic

时间:2017-05-24 08:41:50

标签: javascript jquery html asp.net-mvc javascript-events

<!--I have a problem.

我在mvc c#.net中编写了一个应用程序视图的代码  表单的一部分(该语言具有动态输入,在单击按钮时自动生成)当我必须将@ html.ActionLink发送到存储数据的控制器并将其发送到数据库时,问题仍然存在.preciso使用实体框架 - &gt;

                     Webslesson演示 - 使用JQuery在PHP中动态添加或删除输入字段                                                         

                <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
                <!-- webslesson_mainblogsec_Blog1_1x1_as -->
                <ins class="adsbygoogle"
                     style="display:block"
                     data-ad-client="ca-pub-4529508631166774"
                     data-ad-host="ca-host-pub-1556223355139109"
                     data-ad-host-channel="L0007"
                     data-ad-slot="6573078845"
                     data-ad-format="auto"></ins>
                <script>
                (adsbygoogle = window.adsbygoogle || []).push({});
                </script>
            </div>
            <div class="col-md-9">

                <div class="form-group">
                    <form name="add_name" id="add_name">
                        <div class="table-responsive">
                            <table class="table table-bordered" id="dynamic_field">
                                <tr>
                                    <td><input type="text" name="name[]" placeholder="Lingua" class="form-control name_list" /></td>
                                    <td><button type="button" name="add" id="add" class="btn btn-success">Add More</button></td>
                                </tr>
                            </table>
                            <input type="button" name="submit" id="submit" class="btn btn-info" value="Submit" />
                        </div>
                    </form>
                    <div class="col-md-6">
                <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
                <!-- webslesson_mainblogsec_Blog1_1x1_as -->
                <ins class="adsbygoogle"
                     style="display:block"
                     data-ad-client="ca-pub-4529508631166774"
                     data-ad-host="ca-host-pub-1556223355139109"
                     data-ad-host-channel="L0007"
                     data-ad-slot="6573078845"
                     data-ad-format="auto"></ins>
                <script>
                (adsbygoogle = window.adsbygoogle || []).push({});
                </script>
            </div>


<script>
$(document).ready(function(){
    var i=1;
    $('#add').click(function(){
        i++;
        $('#dynamic_field').append('<tr id="row'+i+'"><td><input type="text" name="name[]" placeholder="Livello" class="form-control name_list" /></td><td><button type="button" name="remove" id="'+i+'" class="btn btn-danger btn_remove">X</button></td></tr>');
    });

    $(document).on('click', '.btn_remove', function(){
        var button_id = $(this).attr("id"); 
        $('#row'+button_id+'').remove();
    });

    $('#submit').click(function(){      
        $.ajax({
            url:"name.php",
            method:"POST",
            data:$('#add_name').serialize(),
            success:function(data)
            {
                alert(data);
                $('#add_name')[0].reset();
            }
        });
    });

});
</script>

0 个答案:

没有答案