Bug Tracker

Modify

Ticket #11981 (closed bug: invalid)

Opened 11 months ago

Last modified 11 months ago

Form create Dinamicaly

Reported by: soares_289@… Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.7.2
Keywords: Cc:
Blocking: Blocked by:

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

comment:1 Changed 11 months 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 months ago by dmethvin

  • Status changed from new to closed
  • Resolution set to invalid

Yep.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.