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)
Tracking
()
RESOLVED
WONTFIX
People
(Reporter: mark, Assigned: jst)
References
()
Details
Attachments
(3 files)
|
544 bytes,
text/html
|
Details | |
|
859 bytes,
text/html
|
Details | |
|
568 bytes,
patch
|
Details | Diff | Splinter Review |
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>
Comment 1•24 years ago
|
||
Browser, not engine ---> Form Submission
Assignee: rogerl → alexsavulov
Component: JavaScript Engine → Form Submission
QA Contact: pschwartau → vladimire
Comment 2•24 years ago
|
||
jkeiser, you know you want this one... :)
Comment 3•24 years ago
|
||
Works if you change <input> name and id to 'itemA'... is 'item' a reservered
word??????
Comment 4•24 years ago
|
||
Updated•24 years ago
|
Comment 5•24 years ago
|
||
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?
| Reporter | ||
Comment 6•24 years ago
|
||
Yeah, sorry, that other server doesn't have a DNS entry - try this one,
although it sounds like you already have it reproduced.
Comment 7•24 years ago
|
||
Comment 8•24 years ago
|
||
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
Comment 9•24 years ago
|
||
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?
Comment 10•24 years ago
|
||
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
Comment 11•24 years ago
|
||
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 }"
Comment 12•24 years ago
|
||
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
| Assignee | ||
Comment 13•24 years ago
|
||
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.
Description
•