代码之家  ›  专栏  ›  技术社区  ›  Christopher

在jQuery中克隆或向表单添加输入不会提交到Firefox中的PHP

  •  1
  • Christopher  · 技术社区  · 17 年前
    $('#images_upload_add').click(function(){
       $('.images_upload:last').after($('.images_upload:last').clone().find('input[type=file]').val('').end());        
    });
    

    使用此代码附加文件输入不会在firefox中上载文件。

    也

    $('#image_server_add input[type=button]').click(function(){
        var select = $(this).siblings('select').find(':selected');
        if(select.val()){
            $('#image_server_add').before('<tr class="images_selection"><td><input type="button" value="Delete"></td><td class="main">'+select.html()+'<input type="hidden" value="'+select.html()+'" name="images_server[]"/></td></tr>');
        }
    })
    

    为什么这些示例不能正确地上传表单值?

    5 回复  |  直到 17 年前
        1
  •  3
  •   Christopher Christopher    17 年前

    表单是基于表的布局,不是我选择的,表单声明在tr中。

    现在,td的父声明移到了表单I的输入。

    我想这与javascript所做的dom操作以及它如何对块级元素要求更严格有关。

        2
  •  1
  •   Prestaul    17 年前

    如果您创建一个新的输入而不是克隆一个现有的输入,您是否也有同样的问题?

    您是更改克隆输入的名称以避免名称冲突,还是使用数组样式名称(例如。 file[] )?

    将所选选项的标记添加到隐藏输入的目的是什么?

    .clone(true) ?

        3
  •  0
  •   meouw    17 年前

    真 的!有时候jQuery实际上可能过于密集而无法读取。如果我们能看到你的标记也会有帮助。
    我猜你想干什么,所以我在暗中捅。

    也许我找错地方了?

        4
  •  0
  •   tobyc    17 年前

    也许不是在提交表单时添加元素,而是使用默认值将元素放入。

    我只是说,因为当您单击submit时,添加的元素与表单一起提交可能已经太晚了。

        5
  •  0
  •   SuperRoach    17 年前

    对我来说,我可以通过退一步解决问题-

    举例来说:

        <table>
    <form method="post">
    <tr>some content <input type="text" name="test"> </tr>
    </form>
    </table>
    

    由于某些原因,这将在internetexplorer中工作,但实际上它是无效的html。 将表单标记移到表外,如下所示:

    <form method="post">
        <table>
    <tr>some content <input type="text" name="test"> </tr>
    </table> 
    </form>
    

    然后它就会起作用。

    推荐文章