Bug Tracker

Opened 11 years ago

Closed 11 years ago

#11981 closed bug (invalid)

Form create Dinamicaly

Reported by: soares_289@… 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();

Change History (2)

comment:1 Changed 11 years ago by anonymous

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.

comment:2 Changed 11 years ago by dmethvin

Resolution: invalid
Status: newclosed

Yep.

Note: See TracTickets for help on using tickets.