<OPTION> No Longer Responds to onClick() or onSelect()

H

Hal Vaughan

I'm using KDE on Linux, with Konqueror as the testing browser for this
project. I've recently upgraded, so I realize some of the bugs I'm dealing
with may or may not be my program, and could also result from me being less
than perfect in my preliminary coding on test pages.

I had an <OPTION> element, 10 lines in size. Previously I used:

onclick="fillFields()"

and when I clicked on a line in the <OPTION> element, the data was
transferred into an input box below. Now when I try the same thing,
nothing happens. I even replaced the original with:

onclick="alert('got click')"

and there was no response. I replaced "onclick" with "onselect", but it
made no difference.

Does this sound like a programming problem, events <OPTION> elements aren't
supposed to respond to, or a bug in the newer version of the browser?

The original HTML code is:

<select size="10" name="selectFilterFields" onselect="fillFields()"
style="font-family: monospace;">

And the new code is:

<select size="10" name="selectFilterFields" style="font-family: monospace;"
onclick="alert('Selected!')">

but neither version works. Am I doing something wrong?

Thanks!

Hal
 
H

Hal Vaughan

I didn't realize I used <OPTION> instead of <SELECT> in the title and post.
s/<OPTION>/<SELECT>/g.

Oops...
 
H

Hal Vaughan

Ivo said:

Thanks, but it doesn't work either (I just tried it). Absolutely NO
response with onfocus.

Is this more likely a browser issue than my programming? (Shouldn't
onclick, onselect, and onfocus all work in this case?)

Hal
 
M

Michael Winter

[snip]
I had an <OPTION> [edit: SELECT] element, 10 lines in size.
Previously I used:

onclick="fillFields()"

and when I clicked on a line in the <OPTION> [edit: SELECT] element,
the data was transferred into an input box below. Now when I try
the same thing, nothing happens. I even replaced the original with:

onclick="alert('got click')"

and there was no response. I replaced "onclick" with "onselect", but
it made no difference.

The onselect event is used when text is selected in an INPUT or TEXTAREA
element, not when you select from a SELECT element.

I just posted a solution to someone else's problem ("Calculated fields")
which uses the onchange event on SELECT elements to update an INPUT, and
it works in Opera, Mozilla, Netscape and IE (all WinXP). If onchange
doesn't work for you, in similar usage, Konqueror is broken. However, if

<select ... onclick="alert('a')">

doesn't display 'a' on-click, it is equally broken.

Mike
 
E

Eric Bohlman

I'm using KDE on Linux, with Konqueror as the testing browser for this
project. I've recently upgraded, so I realize some of the bugs I'm
dealing with may or may not be my program, and could also result from
me being less than perfect in my preliminary coding on test pages.

I had an <OPTION> element, 10 lines in size. Previously I used:

onclick="fillFields()"

and when I clicked on a line in the <OPTION> element, the data was
transferred into an input box below. Now when I try the same thing,
nothing happens. I even replaced the original with:

onclick="alert('got click')"

and there was no response. I replaced "onclick" with "onselect", but
it made no difference.

Have you run your HTML through a validator? If not, do so and fix any
errors that it points up. It's often the case that new versions of
browsers change the way they deal with invalid HTML, often causing
something that "worked" in a previous version to fail in the new version.
Plainly what's going on is that Konqueror isn't paying any attention to
your action attributes (since your "alert" example is plainly correct
Javascript); the reason may be that its parser is getting out of sync due
to some invalid HTML. Come to think of it, make sure you haven't
inadvertently disabled Javascript in the browser as well.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,438
Messages
2,571,699
Members
48,796
Latest member
Greg L.
Top