Closed Bug 210862 Opened 21 years ago Closed 16 years ago

form submission fails with html form created using javascript

Categories

(Core :: DOM: Core & HTML, defect)

x86
Linux
defect
Not set
major

Tracking

()

RESOLVED FIXED

People

(Reporter: shreeguru_ks, Unassigned)

References

Details

(Keywords: html5, testcase)

Attachments

(4 files, 1 obsolete file)

User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021130 Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021130 When I create the html form with Javascript and try to do a submit of the form nothing happens in Mozilla ( also netscape 7 which is from Mozilla). It works fine with IE and netscape 4.X versions. I feel that it is broken feature for netscape 7. In the steps I have given the code where I use, perl for the backend. I have tested this with latest Mozilla 1.4. It doesnot work. Reproducible: Always Steps to Reproduce: 1. Install the minutes.pl, dummy.pl and inet.pl in the http server machine in the bin directory where we can run perl scripts for cgi. Just need to run the minutes.pl script from the Mozilla browser as, http://<server>/cgi-bin/minutes.pl 2.Scripts are, * ~~~~~~~~~~~~~~~ minutes.pl ~~~~~~~~~~~~~~~ #!/usr/contrib/bin/perl print("Content-Type: text/html\n\n"); $submit_selected = 0; # No of each row elements VIP for adding new fields1` $min_ai_columns=2; print"<HTML>\n"; print"<HEAD>\n"; read(STDIN,$save_string,$ENV{"CONTENT_LENGTH"}); if ($save_string ne "") { $submit_selected = 1; } print"<SCRIPT LANGUAGE=\"JavaScript1.1\">\n"; print"var min_ai_instance = \'\';\n"; print"var no_of_min_ai_rows = \'\';\n"; print"function Obj() {\n"; print" this.things = new Array();\n"; print"}\n"; print"function dummyObj() {\n"; print" this.dname; // simply a member\n"; print"}\n"; print"\n"; print"function Initialise() {\n"; print" min_ai_instance = new Obj();\n"; print"}\n"; print"function dosomething() {\n"; print" Initialise();\n"; ## Preloaded min_ai data put it in javascript ############################################################### $i=0; if($min_ai_index != 0) { $j=($min_ai_index/$min_ai_columns); } else { $j=0; } print " no_of_min_ai_rows = $j;\n"; $temp=0; while($i < $j) { print" min_ai_instance.things[$i]=new dummyObj();\n"; print" min_ai_instance.things[$i].min_ai_summary=\'@min_ai_array[$temp++]\';\n"; print" min_ai_instance.things[$i].min_ai_state=\'@min_ai_array[$temp++]\';\n"; print" min_ai_instance.things[$i].min_ai_rem=\'\';\n"; $i++; } print"}\n"; print"dosomething();\n"; print"</SCRIPT>\n"; print"</HEAD>\n"; print"<FRAMESET ROWS=\"100%,1%\">\n"; print" <FRAME SRC=\"./dummy.pl\">\n"; #print" <FRAME SRC=\"./inet.pl\" NORESIZE>\n"; print" <FRAME SRC=\"./inet.pl\">\n"; print"</FRAMESET>\n"; print"</HTML>\n"; * ~~~~~~~~~~~~~~ dummy.pl ~~~~~~~~~~~~~~ #!/usr/contrib/bin/perl print("Content-Type: text/html\n\n"); print"<HTML>\n"; print"<HEAD>\n"; print"<TITLE>Minutes</TITLE>\n"; print"</HEAD>\n"; print"</HTML>\n"; * ~~~~~~~~~ inet.pl ~~~~~~~~~ #!/usr/contrib/bin/perl print("Content-Type: text/html\n\n"); $submit_selected = 0; # No of each row elements VIP for adding new fields $min_ai_columns=2; print"<HTML>\n"; print"<HEAD>\n"; read(STDIN, $save_string, $ENV{"CONTENT_LENGTH"}); if ($save_string ne "") { $submit_selected = 1; &parse_submitted_vars(); } if( $submit_selected == 0 ) { &Display_the_forms; } sub parse_submitted_vars { print "$save_string"; # Save it $datafile = "./database.mins"; open(DB, ">$datafile"); print DB $save_string; close(DB); } ########### # Display the form sub Display_the_forms { print"<SCRIPT LANGUAGE=\"JavaScript1.1\">\n"; print"\n"; print"var infoStr = '';\n"; print"var temparray;\n"; print"var min_ai_instance;\n"; print"var min_taken_date = '';\n"; print"var min_ai_instance_no_of_rows=0;\n"; print"var min_ai_columns=3;\n"; print"var min_ai_state_array = new Array(\"NEW\", \"ONGOING\", \"CLOSED\");\n"; print"function Obj() {\n"; print" this.things = new Array();\n"; print"}\n"; print"function dummyObj() {\n"; print" this.dname; // simply a member\n"; print"}\n"; print"\n"; print"function Initialise() {\n"; print" min_ai_instance = new Obj();\n"; print"\n"; print"}\n"; print"function global_fn() {\n"; print"Initialise();\n"; ############ Pre load the variables for min_ai print"temparray = new Array();\n"; print"min_ai_instance.things = temparray;\n"; print"var no_of_min_ai_rows = window.parent.no_of_min_ai_rows;\n"; print"for(var i=0; i < no_of_min_ai_rows; i++) {\n"; print" min_ai_instance.things[i] = new dummyObj();\n"; print" min_ai_instance.things[i]=window.parent.min_ai_instance.things[i];\n"; print"}\n"; print"show_data_contents();\n"; print"}\n"; print"function freshstart1()\n"; print"{\n"; print"global_fn();\n"; print"}\n"; print"function genOption(opt_str, opt_selected)\n"; print"{\n"; print" var temp=\'\';\n"; print"\n"; print" for(var i=0; i < opt_str.length; i++) {\n"; print" temp += \'<OPTION\' ;\n"; print" if(opt_selected == opt_str[i])\n"; print" temp += \' SELECTED>\';\n"; print" else \n"; print" temp += \'>\';\n"; print" temp += opt_str[i];\n"; print" }\n"; print" return temp;\n"; print"}\n"; print"\n"; print"function giveSelectStr(formEle, strArr)\n"; print"{\n"; print" for(var i=0; i < strArr.length; i++) {\n"; print" if(formEle.options[i].selected) {\n"; print" return strArr[i];\n"; print" }\n"; print" }\n"; print"}\n"; print"\n"; print"function onSubmitMin(formObj)\n"; print"{\n"; print" var mylen;\n"; print" var i;\n"; print" min_ai_instance_no_of_rows = min_ai_instance.things.length;\n"; print" add_min_ai_row(formObj,1,0);\n"; print" return true;\n"; print"}\n"; print"function get_min_ai_data()\n"; print"{\n"; print" var intro=\'<FORM METHOD=POST ACTION=\"./inet.pl\">\' +\n"; print "\'<INPUT TYPE=\"hidden\" NAME=\"minForm\" VALUE=\"minForm\">\' +\n"; print" \'<TD><FONT SIZE=\"-1\"><B>Meeting Date <INPUT TYPE=text NAME=min_taken_date size=16 \' +\n"; print" \'value=\\\"\' + min_taken_date + \'\\\">(dd/mm/yyyy)</TD><BR><H4><B>Action Items<br>\'+\n"; print" \'<FONT SIZE=\"-1\"><INPUT TYPE=BUTTON VALUE=\"NEW\" onClick=\"parent.frames[1].new_min_ai_row(this.form,0,1);\">\' +\n"; print" \'<INPUT TYPE=BUTTON VALUE=\"UPDATE\" onClick=\"parent.frames[1].new_min_ai_row(this.form,1,1);\"><FONT SIZE=\"-1\"> \';\n"; print"\n"; print" var tableTop=\'<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=1>\' +\n"; print" \'<TR><TH><B><FONT SIZE=\"-1\">Action Item Summary\' +\n"; print" \'<TH><B><FONT SIZE=\"-1\">State\' +\n"; print" \'<TH><B><FONT SIZE=\"-1\">Rem\' +\n"; print" \'</TR>\';\n"; print"\n"; print" var datastr=\'\';\n"; print" mylen = min_ai_instance.things.length;\n"; print" \n"; print" for(var i=0; i < mylen; i++ ) {\n"; print" datastr += \'<TR> \' +\n"; print" \'<TD ALIGN=LEFT><FONT SIZE=\"-1\"> <textarea NAME=\"min_ai_summary\" rows=2 cols=28>\' \n"; print" + min_ai_instance.things[i].min_ai_summary + \'</textarea> </TD>\'+\n"; print" \'<TD><FONT SIZE=\"-1\"> <SELECT NAME=min_ai_state size=1>\';\n"; print" datastr += genOption(min_ai_state_array,min_ai_instance.things[i].min_ai_state);\n"; print" datastr += \'</SELECT></TD>\'+\n"; print" \'<TD ALIGN=CENTRE><FONT SIZE=\"-1\"> <INPUT TYPE=CHECKBOX></TD>\'+\n"; print" \'</TR>\';\n"; print" }\n"; print" var footer=\'</TABLE>\';\n"; print" return ( intro + tableTop + datastr + footer) ;\n"; print"}\n"; print" \n"; print"function show_data_contents()\n"; print"{\n"; print"\n"; print" var header=\'<HTML><HEAD><TITLE>Minutes</TITLE>\' +\n"; print" \'</HEAD><BODY bgcolor=\"ffcccc\"><H2>Minutes Data</H2>\';\n"; print" var min_ai_str = get_min_ai_data();\n"; print"\n"; print" footer = \'<B><BR></FONT><FONT SIZE=\"3\"><INPUT TYPE=\"SUBMIT\" VALUE=\"Display Submit\" onClick=\"return parent.frames[1].onSubmitMin(this.form);\">\' +\n"; print" \'</FORM></BODY></HTML>\';\n"; print" infoStr= header + min_ai_str + footer;\n"; print" parent.frames[0].location.replace(\'javascript:parent.frames[1].infoStr\');\n"; print"}\n"; print"\n"; print"function new_min_ai_row(formObj,update,show_data_contents)\n"; print"{\n"; print" min_ai_instance_no_of_rows = min_ai_instance.things.length;\n"; print" add_min_ai_row(formObj,update,show_data_contents);\n"; print"}\n"; print"function add_min_ai_row(formObj,update,show_data_contents)\n"; print"{\n"; print" var mylen;\n"; print" var temp;\n"; print" var i;\n"; print" var j;\n"; print" var temp1;\n"; print" \n"; print" var temparray = new Array();\n"; print"\n"; print"min_taken_date = formObj.elements[1].value;\n"; print" i=0; \n"; print" if(min_ai_instance.things.length == 0) {\n"; print" mylen = 0;\n"; print" if(update)\n"; print" return;\n"; print" } else {\n"; print" mylen = min_ai_instance.things.length;\n"; print" temp1 = 3;\n"; print" for(j=0; j < mylen; j++ ) {\n"; print" temp = temp1 + j * min_ai_columns;\n"; print" \n"; print" if(!formObj.elements[temp+3].checked) {\n"; print" temparray[temparray.length] = min_ai_instance.things[i];\n"; print" temparray[temparray.length - 1].min_ai_summary=formObj.elements[temp+1].value;\n"; print" temparray[temparray.length - 1].min_ai_state=giveSelectStr(formObj.elements[temp+2],min_ai_state_array);\n"; print" temparray[temparray.length - 1].min_ai_rem=formObj.elements[temp+3].checked;\n"; print" i++;\n"; print" }\n"; print" } \n"; print" \n"; print" }\n"; print" \n"; print" min_ai_instance.things = temparray;\n"; print" i= min_ai_instance.things.length;\n"; print" if( update != 1 ) {\n"; print" min_ai_instance.things[i]=new dummyObj();\n"; print" min_ai_instance.things[i].min_ai_summary=\'\';\n"; print" min_ai_instance.things[i].min_ai_rem=\'\';\n"; print" } \n"; print" \n"; print" if(show_data_contents == 1)\n"; print" parent.frames[1].show_data_contents();\n"; print"}\n"; print"\n"; print"\n"; print"</SCRIPT>\n"; print"</HEAD>\n"; print"<BODY onLoad=\"parent.frames[1].freshstart1();\">\n"; print"</BODY>\n"; print"</HTML>\n"; } Actual Results: When I submit the form, nothing happens. Expected Results: It should have sent the forms to the http server.
please save the form page ("HTML only", not "complete") from Mozilla and attach it to this bug (Create a New Attachment)
Attached file Main html file (deleted) —
This is the main html file which will be invoked first.
Attached file frame1 which does the main JOB (deleted) —
I have extracted html from the perl script. All the 3 scripts should be together to make this work properly.
Attached file testcase (obsolete) (deleted) —
this loads a bogus page in a single frame and then replaces it with appropriate html. in the resulting page, the first form's action is "/query.cgi". In the second form, the action is "http://bugzilla.mozilla.org/". Submitting the first does nothing. Submitting the second works fine. If the html is not javascript-generated, both forms work fine.
Attached file testcase (deleted) —
forgot security checks...
Attachment #126659 - Attachment is obsolete: true
confirmed with linux turnk 20030626
Status: UNCONFIRMED → NEW
Ever confirmed: true
Keywords: testcase
Um... You have a relative action URI. And you set the URI of the document in the form to "javascript:parent.infoStr" explicitly. Resolving a relative URI relative to that fails, so the action URI is invalid. This is not a form submission problem -- using an anchor with a relative URI would do the same. Over to DOM, since a javascript: url is involved, but I doubt we plan to change this behavior...
Assignee: form-submission → general
Component: HTML: Form Submission → DOM: Level 0
QA Contact: ashshbhatt → ian
Depends on: 49312
I am having similar problems with firefox ever since. What I do is: I got a select with possible actions. When i choose one action, the fields of the form are changed by js, fields are added or removed. Now, what happens is, form data gets POSTed correctly for all static form fields. The dynamic form fields are not POSTed at all (the ones inserted by the action-select) This works fine on any IE version i tried. sample code: // JS Function to change form: <script language="JavaScript" type="text/JavaScript"> <!-- function changeAdmintd() { adminform = document.PSS_admin.a; selected = adminform.options[adminform.selectedIndex].value; if (selected == "addkey" || selected == "delkey") { document.getElementById("td_adminform").innerHTML = '<img src="/pss/0.gif" width="1" height="10" alt="" border="0"><br />Suchbegriffe:<br /><select name="iKeyword" class="pss_formselect" style="width:300;"><option value="1">cat1key1</option><option value="2">cat1key2</option><option value="3">cat1key3</option><option value="4">cat2key1</option><option value="5">cat2key2</option><option value="6">cat2key3</option></select>'; } else if (selected == "comment") { document.getElementById("td_adminform").innerHTML = '<img src="/pss/0.gif" width="1" height="10" alt="" border="0"><br />Kommentar:<br /><select name="sCommentlang" class="pss_formselect" style="width:300;"><option value="de" selected>Deutsch</option><option value="en">Englisch</option></select><br /><textarea cols="8" rows="5" name="sComment" class="pss_formtext" style="width:300px; height:100px;"></textarea>'; } else if (selected == "chown") { document.getElementById("td_adminform").innerHTML = '<img src="/pss/0.gif" width="1" height="10" alt="" border="0"><br />Benutzer:<br /><select name="iUser" class="pss_formselect" style="width:300;"><option value="" selected></option><option value="5">Demo</option><option value="4">hanz</option><option value="1">Marcus Haase</option></select>'; } else { document.getElementById("td_adminform").innerHTML = ""; } } //--> </script> // select wich triggers JS function <select name="a" class="pss_formselect" onChange="changeAdmintd();" style="width:300;"> <option value="null"></option> <option value="link">Ausgewählte Dateien verknüpfen</option> <option value="comment">Dateikommentar ändern</option> <option value="chown">Dateibesitzer ändern</option> <option value="addkey">Suchbegriff verknüpfen</option> <option value="delkey">Suchbegriff entfernen</option> <option value="unlink">Dateiverknüpfung entfernen</option> </select> // Area changed by JS function <td colspan="3" id="td_adminform" class="pss_main"></td>
Marcus Haase, you're not seeing this bug, and there is about a 99% chance that what you are seeing is correct behavior, based on the fairly incomplete data you have provided. If you're sure Mozilla's behavior is wrong, please file a separate bug, cc me on it, and attach an actual HTML page that shows the problem (as an attachment, not pasted into the bug).
I kind of wonder what HTML5 has to say about this...
Keywords: html5
Actually, I later found out, what produces this bug for me, its using JS and innerHTML to add form fields to the page. The fields added thru innerHTML are ignored in further processing. This behavior (I dont call it a bug anymore) is reproducable in all browsers but IE wich behaves the way I prefer (does process the added form fields). If anyone is interested I can write a real short example.
Marcus, see comment 10.
Does this (the original problem not the unrelated one discussed in comment 9) work in any other version of firefox, or any other browser? Like bz, it does seem to me like we are doing the "right" thing here
I tested Andrew's testcase last night in various browsers. IE gives security exceptions all over and the testcase doesn't go anywhere at all (no buttons), or so I'm told. It "works" in Safari by never changing the location of the iframe, even after the javascript: URI is executed. It works in Opera, as far as I can tell, by not changing the baseURI of the javascript: document from the baseURI of the document that used to be there but setting its URI to the javascript: string. In other words, there is no real interoperability here, though some things behave the same across some browsers.
Blocks: 359190
Blocks: 366057
This got effectively fixed by the fix for bug 445004, and the test for bug 132255 tests this.
Status: NEW → RESOLVED
Closed: 16 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
No longer blocks: 366057
No longer blocks: 359190
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: