Closed Bug 11703 Opened 21 years ago Closed 21 years ago

{formname}.submit does not work

Categories

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

x86
Windows NT
defect

Tracking

()

VERIFIED WORKSFORME

People

(Reporter: kmcclusk, Assigned: vidur)

References

()

Details

(Whiteboard: [TESTCASE] can't access forms via {formname} in onClick handler)

Attachments

(1 file)

Go to the url above and click on the Search By: radio buttons. Clicking on the
radio button performs a formname.submit() in a onclick mouse handler for the
radio button. a JavaScript error: FormSearch is not defined is output.


The following test case has two buttons. The first button causes the page to
change by first using getElementById then invoking submit. The second button
uses the name of the form to invoke the submit. The first button works, the
second one doesn't. There doesn't seem to be any problem with the buttons. The
problem seems to be that JavaScript can not find the form element when you refer
to it by it's name attribute.

<html>
<head>
<script>
  function changepage()
  {
    var el = document.getElementById("formid");
    el.submit();
  }
</script>
</head>
<body>
<form METHOD="GET" ACTION="http://search.yahoo.com/bin/search" id=formid
NAME="searchform">
<input type=button value="use searchform.submit" onclick="searchform.submit();">
<input type=button value="use getElementById" onclick="changepage();">
</form>
</body>
</html>
Attached file Example as attachment
Whiteboard: [TESTCASE] can't access forms via {formname} in onClick handler
Vidur,
In the testcase the code onclick="searchform.submit();" doesn't work. (This is
how the microsoft page above codes it)
HOWEVER, changing it to onclick="document.searchform.submit();" works!
What is the scope chain supposed to look like inside an onClick handler in a
form?  (Win98 19990816 nightly build)
And, BTW, the original submitter had it switched around. The first button
doesn't work, the second button works.
See also worldzone.net/misc/lesch/main.html for another example.
QA Contact update.
Status: NEW → RESOLVED
Closed: 21 years ago
Resolution: --- → WORKSFORME
This must have been fixed some where along the way, because it works fine with
the latest build
Updating QA contact.
QA Contact: ckritzer → vladimire
Verifying on
-Windows98 build 2000-09-26-08-M18
-Linux RedHat6.2 build 2000-09-27-08-M18
Status: RESOLVED → VERIFIED
regression in 57.0 returns undefined and doesn't always work.
Component: HTML: Form Submission → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.