小编nya*_*nko的帖子

表单不提交动态生成的输入(jQuery)

您好我正在尝试为我的表单动态生成一些输入,但它不会发布生成的新输入,到目前为止我一直在搜索,我唯一能找到的是使表单成为身体标签,以及在我的应用程序的设计中,这是不可能的,所以有人可能知道会发生什么以及如何解决它?不,它不起作用.live().

HTML

 <form name="order" id="newOrder" action="../core/query.php" method="post">
        <input type="text" value="Search" id="itemSearch" class="search"/>
        <input type="hidden" id="itemAdd"/>
        <button type="button" class="boton" id="additem">Add</button> 
        <br>
        <div id="items"></div>
        <br>
        <button type="submit" class="boton" > Submit</button>
        <button type="reset" class="boton" style="float:right;"> Cancel</button>
        </div>
    </form>

Javascript

  $('#additem').click(function(){
if($('#itemAdd').val()){
    var rawr = $('<div></div>')
    .css('display','none')
    .html(  '<br><table><td>'
            +currItem.label+'</td><td> Size '
            +currItem.size+'</td><td class="right">$'+currItem.price
            +'</td></table> <input type="hidden" name="contents[]" value="'
            +currItem.value+'"/>');
    var mhm = currItem.price;
    rawr.appendTo('#items').toggle(500).click(function(){
        $(this).toggle(500,function(){
            $(this).remove();
        });
        $('#total').fadeOut("fast",function(){
            total = (parseFloat($(this).text())-parseFloat(mhm)).toFixed(2);
            $(this).text(total).fadeIn("fast");
        });
    });
    $('#total').fadeOut("fast",function(){
        total = (parseFloat($(this).text())+parseFloat(mhm)).toFixed(2);
        $(this).text(total).fadeIn("fast");
        currItem=null;
    }); …
Run Code Online (Sandbox Code Playgroud)

forms jquery input dynamic

7
推荐指数
2
解决办法
1万
查看次数

标签 统计

dynamic ×1

forms ×1

input ×1

jquery ×1