"this.x" does not check for x in parent nodes

RESOLVED INVALID

Status

()

--
minor
RESOLVED INVALID
16 years ago
16 years ago

People

(Reporter: hfmeza, Assigned: john)

Tracking

Trunk
x86
Windows 98
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(2 attachments)

(Reporter)

Description

16 years ago
Apparently the onchange event is not being correctly triggered in a web form.

Consider the following code (extracted from www.canalsony.com)

<script>
function redir()
{
window.location.href = this.listaserie.serielista.value;
}
</script>

<body>
      <div align="right">
       <form action="redirserie.asp" name="listaserie" method="post">
      <select name="serielista" size="4" onchange="redir()">

                                <option
value="/programacao/hot_sites/series/3rdrock/3rdrock.asp">3rd Rock from the
Sun</option>
                                <option
value="/programacao/hot_sites/series/7th_heaven/7th_heaven.asp">7th Heaven</option>
                                <option
value="/programacao/hot_sites/series/according_to_jim/according_to_jim.asp">According
to Jim</option>
                                <option
value="/programacao/hot_sites/series/asif/asif.asp">As If</option>
      </select>
          </form>
      </div>
</body>
</html>

When the user clicks on one of the select options, the browser should be
redirected accordingly (which happens when the page is tested in Opera 6.01).
When this is done in Mozilla 1 rc2 2002051006, nothing happens.

Comment 1

16 years ago
Browser, not engine. This probably should be sent to Event Handling,
but allow me to send to HTML Form Controls first in case this is
a known issue -
Assignee: rogerl → jkeiser
Component: JavaScript Engine → HTML Form Controls
QA Contact: pschwartau → tpreston
(Assignee)

Comment 2

16 years ago
Created attachment 97108 [details]
Minimized Testcase

OnChange fires fine, but JS can't find the select.  The problem is that
"this.formname" doesn't work, because formname is not a property of this (which
is the select node).  If you remove "this" it works, as the testcase
shows--that is because to find variables we look up the tree from the node
until we find the variable as an attribute.  I heavily suspect this is INVALID.
(Assignee)

Comment 3

16 years ago
Marking INVALID but CC'ing jst and bz in case this was an unknown issue (I
suspect it wasn't).
Status: UNCONFIRMED → RESOLVED
Last Resolved: 16 years ago
Resolution: --- → INVALID
Summary: onchange event not being triggered? → "this.x" does not check for x in parent nodes
(Reporter)

Comment 4

16 years ago
Created attachment 97127 [details]
testcase related to this.x

I've been looking into this bug, and I believe the problem is not only related
to this.x, but to something that appears to be variable scope. I think it's
probably correct in relation to javascript compliance, but since I don't know
that much about javascript, and it works on opera and ie, i'll post it here.

IN the test case, there are 3 text inputs, the first has a
onchange:"alert(textinput.value)", that works perfectly. The third one calls a
function sending the form as a parameter. THe function does the same alert. It
works.

The second one calls the function, without sending a parameter, and it doesn't
work, because, according to the console, the form is not defined. Probably it's
because of the form not being accesible from the function, but since it works 2
other browsers, maybe it could be implemented for compatibility's sake?

I'm sorry if this bug is considered closed, or if this is totally senseless.
You need to log in before you can comment on or make changes to this bug.