Closed Bug 126160 Opened 24 years ago Closed 24 years ago

Setting hidden field from javascript sets it in DOM but it is blank when posted.

Categories

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

x86
Windows 2000
defect

Tracking

()

RESOLVED WONTFIX

People

(Reporter: mark, Assigned: jst)

References

()

Details

Attachments

(3 files)

When you click on 'click me' in the supplied URL, some javascript sets the hidden field called 'item'. The alert box outputs the value of 'item' to prove it has been set. However, when the form is submitted in the next line, the 'item' field is not posted to the server. This works from IE6 and Netscape 4.72. This fails with Mozilla Build 2002020406 - I haven't tried any other builds. The following code fragment reproduces the problem. Obviously you need to put it on machine with ASP (or change the ASP bit to output the form value from a different server-side language). <html> <body bgcolor="#ffffff"> <script language="javascript"> function AddItem(lid) { document.forms['mainform'].elements['item'].value = lid; alert(document.forms['mainform'].elements['item'].value); document.forms['mainform'].submit(); } </script> <% response.write("<p>item=" + request.form("item")) %> <form name="mainform" id="mainform" method="post" action="test2.asp"> <input type="hidden" name="item" id="item"/> <p><a href="javascript:AddItem(775968)">click me</a> </form> </body> </html>
Browser, not engine ---> Form Submission
Assignee: rogerl → alexsavulov
Component: JavaScript Engine → Form Submission
QA Contact: pschwartau → vladimire
jkeiser, you know you want this one... :)
Works if you change <input> name and id to 'itemA'... is 'item' a reservered word??????
Arr, sorry, hit enter. Nonetheless, I can't get to the testcase. Since I presume you are still here, could you post an IP or similarly working URL?
Yeah, sorry, that other server doesn't have a DNS entry - try this one, although it sounds like you already have it reproduced.
Attached file Test case with GET
Made a simplified test case using GET instead of post & showing that this works for fields with names other Instead of tracking the submit via "Item =" on the page watch the location field... clicking on the first link submits a form with item, incorrectly showing "?item=#" at the end of the URL clicking on the second link submits a form with the field name & id changed to blah and correcly yields "?blah=775968#" Also, I'm seeing this on OS X/0.9.9
OK, the problem is in the DOM form access. document.mainform.item.value works. document.mainform.elements['item'].value does not. document.mainform.elements['blah'].value works, however, so it seems the elements array contains all the properties of the form including the functions?
Reassigning to DOM. Fabian, Pete, this is right smack down your alley :)
Assignee: alexsavulov → jst
Status: UNCONFIRMED → NEW
Component: Form Submission → DOM HTML
Ever confirmed: true
QA Contact: vladimire → stummala
see following code: http://lxr.mozilla.org/seamonkey/source/dom/public/idl/html/nsIDOMHTMLCollection .idl and http://lxr.mozilla.org/seamonkey/source/dom/public/idl/html/nsIDOMHTMLFormElemen t.idl#46 elements(nsIDOMHTMLCollection) is a member of nsIDOMHTMLFormElement, and item is an member of nsIDOMHTMLCollection. So, it's the reason why "document.mainform.elements['item'].value" returns undefined. I also tried "document.mainform.elements['item']" it return "function item(){ native code }"
For the moment we resolve the property in the following order: 1) Find a method or property with that name 2) Find an element with that id/name We would have to resolve the property in the opposite order to fix this "bug". I think we've wontfixed several similar bugs about "submit" for forms. Thoughts?
Severity: minor → normal
Priority: -- → P4
Yup, WONTFIX.
Status: NEW → RESOLVED
Closed: 24 years ago
Resolution: --- → WONTFIX
Component: DOM: HTML → DOM: Core & HTML
QA Contact: stummala → general
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: