Skip to main content

Bug Tracker

Side navigation

#11981 closed bug (invalid)

Opened June 27, 2012 07:39PM UTC

Closed July 03, 2012 05:13PM UTC

Form create Dinamicaly

Reported by: soares_289@hotmail.com Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.7.2
Keywords: Cc:
Blocked by: Blocking:
Description

When creating a form via jquery and use the method submit, a new window is open in Chrome and the submit go to the wrong place. In Safari and FireFox the submit don`t send.

The code used:

var form = $("<form method=\\"post\\" enctype=\\"multipart/form-data\\" name=\\"uploadFile\\" target=\\"index.php\\"></form>");

var file = $("<input type=\\"file\\" name=\\"file1\\" id=\\"upload\\" />");

$(form).append( file );

file.change(function(){

$("#save").click();

$(form).submit();

});

file.click();

I solve the problem with this:

var form = document.createElement("form");

var file = $("<input type=\\"file\\" name=\\"file1\\" id=\\"upload\\" />");

$(form).attr("method","post");

$(form).attr("action","index.php");

$(form).attr("enctype","multipart/form-data");

$(form).append( file );

file.change(function(){

$(form).submit();

});

file.click();

Attachments (0)
Change History (2)

Changed June 27, 2012 09:55PM UTC by anonymous comment:1

You have to use the action-attribut, not the target-attribut.

In the second example you're doing it, right, in the first it is wrong.

Changed July 03, 2012 05:13PM UTC by dmethvin comment:2

resolution: → invalid
status: newclosed

Yep.