Closed Bug 66086 Opened 25 years ago Closed 25 years ago

Form doesn't submit via A HREF='javascript:this.document.forms[0].submit()'

Categories

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

x86
Linux
defect
Not set
normal

Tracking

()

VERIFIED FIXED

People

(Reporter: bodlak, Assigned: jst)

References

()

Details

From Bugzilla Helper: User-Agent: Mozilla/5.0 (X11; U; Linux 2.2.14-6.0.1 i686; en-US; 0.7) Gecko/20010112 BuildID: 2001011213 In form there is a form and in this form Anchor which is expected to submit form (see URL above - right frame) but it doesn't! Both IE on Win and NN 4.72 on Linux works with this HTML code. The Anchor is named "submit". Reproducible: Always Steps to Reproduce: Try enter some data into both inputs (they are login name and password). The form should be submitted and will probably say "you are wrong" in czech - does not allow you to log in. Actual Results: When I press the login anchor, somethnig happens in background, but with no result. This page is still on screen and is not correctly sent. Everything seemt to be OK, only it doesn't submit anything. Expected Results: You should be sent to another page. In this page there will be red text in bottom part saying "hoho, no enter for you!" in czech. I think it may be connected with javascript object hierarchy interpretation in Mozilla (what actually is THIS in form?). I tried to find this bug in bugzilla database - no success. PLS be patient with me, as I am new to bugzilla.
This code won't work in mozilla: <a href="javascript:this.document.forms[0].submit()"> Changing it to the following fixes the problem: <a href="javascript:document.forms[0].submit()"> (this.document. vs just document.) Over to DOM, not sure this is something that _should_ be fixed, but 4.x and IE submit the form.
Assignee: rods → jst
Status: UNCONFIRMED → NEW
Component: Form Submission → DOM Level 0
Ever confirmed: true
QA Contact: vladimire → desale
Summary: Form doesn't submit via A HREF='javascript:... → Form doesn't submit via A HREF='javascript:this.document.forms[0].submit()'
>(what actually is THIS in form?)< The 'this' keyword refers to the current object. In general, in a method this refers to the calling object. You may use it to check the value of input.value of an input element. Like this example: <script type="text/javascript> <!-- function someFunc(obj) { alert(obj.value); return; } </script> Then you need something like this to call that function: <input type="text" name="lastname" size="25" onChange="someFunc(this)"> When you type Bodlak in this input element, then someFunc will generate a small message with your lastname in it. BTW the syntax is: this[.propertyName]
Status: NEW → RESOLVED
Closed: 25 years ago
Resolution: --- → FIXED
Problem solved. Your first anwer is bad. This javascript syntax *does* work in other pages when used. This page's problem was naming of the anchor submitting form. I named it "submit" and this is why javascript told me "submit is not a function" in javascript console window. So I renamed anchor to "login" and voila! everything works OK. BTW, I relly know what "this" means, I wondered if "this" was "document" or "form" or something other in this page context. :-) Pls, speed up javascript module!!! Bye for nww.
My comment is exactly conform ECMAscript specs. I only used my example to make it clear, because you're the one asking about this, but no problem. BTW, this bug should be marked worksforme and not fixed, because the errors was in your code!
There was a problem with code itself. Its working perfect. No problems. Marking Verified.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.