473,385 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

OnChange Javascript - IE vs Firefox

Hi Guys,

I'm having a HUGE problem with Javascript under IE, the code below belongs
to a page
http://filterqueen.brinkster.net/test.aspx

it works fine under Firefox, but not in IE...

does anyone knows how to add OnChange Script to work under IE as well?

-----------------------------------------
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs)
rbl.Attributes.Add("onchange", "javascript: alert('me :)');")
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Test Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:RadioButtonList runat="server" ID="rbl" RepeatDirection="Horizontal">
<asp:ListItem Value="1" Text="1" ></asp:ListItem>
<asp:ListItem Value="2" Text="2" ></asp:ListItem>
<asp:ListItem Value="3" Text="3" ></asp:ListItem>
</asp:RadioButtonList>
</form>
</body>
</html>

-----------------------------------------

--

Bruno Alexandre
(a Portuguese in Københanv, Danmark)


Jun 12 '06 #1
7 8242
For one thing, your script is incorrect. You can remove the
"javascript:" portion.

Bruno Alexandre wrote:
Hi Guys,

I'm having a HUGE problem with Javascript under IE, the code below belongs
to a page
http://filterqueen.brinkster.net/test.aspx

it works fine under Firefox, but not in IE...

does anyone knows how to add OnChange Script to work under IE as well?

-----------------------------------------
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs)
rbl.Attributes.Add("onchange", "javascript: alert('me :)');")
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Test Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:RadioButtonList runat="server" ID="rbl" RepeatDirection="Horizontal">
<asp:ListItem Value="1" Text="1" ></asp:ListItem>
<asp:ListItem Value="2" Text="2" ></asp:ListItem>
<asp:ListItem Value="3" Text="3" ></asp:ListItem>
</asp:RadioButtonList>
</form>
</body>
</html>

-----------------------------------------

Jun 12 '06 #2
nop...

You are wrong.

1st we need to supply the language, like if you wanna print the page you
scecified

<a href="javascript: window.print();" >

and not only window.print(); ...

thans a W3C thing!
and secondly, even if I delete it still doesn't work :-(
--

Bruno Alexandre
(a Portuguese in Københanv, Danmark)
"Ray Booysen" <rj***********@rjb.za.net> escreveu na mensagem
news:%2****************@TK2MSFTNGP04.phx.gbl...
For one thing, your script is incorrect. You can remove the "javascript:"
portion.

Bruno Alexandre wrote:
Hi Guys,

I'm having a HUGE problem with Javascript under IE, the code below
belongs to a page
http://filterqueen.brinkster.net/test.aspx

it works fine under Firefox, but not in IE...

does anyone knows how to add OnChange Script to work under IE as well?

-----------------------------------------
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs)
rbl.Attributes.Add("onchange", "javascript: alert('me :)');")
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Test Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:RadioButtonList runat="server" ID="rbl"
RepeatDirection="Horizontal">
<asp:ListItem Value="1" Text="1" ></asp:ListItem>
<asp:ListItem Value="2" Text="2" ></asp:ListItem>
<asp:ListItem Value="3" Text="3" ></asp:ListItem>
</asp:RadioButtonList>
</form>
</body>
</html>

-----------------------------------------

Jun 12 '06 #3
and one more...

it's ONLY FOR RadioButtonList...

all my DropDownList are working perfectly with that syntax, in IE and
Fireworks!

--

Bruno Alexandre
(a Portuguese in Københanv, Danmark)
"Ray Booysen" <rj***********@rjb.za.net> escreveu na mensagem
news:%2****************@TK2MSFTNGP04.phx.gbl...
For one thing, your script is incorrect. You can remove the "javascript:"
portion.

Bruno Alexandre wrote:
Hi Guys,

I'm having a HUGE problem with Javascript under IE, the code below
belongs to a page
http://filterqueen.brinkster.net/test.aspx

it works fine under Firefox, but not in IE...

does anyone knows how to add OnChange Script to work under IE as well?

-----------------------------------------
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs)
rbl.Attributes.Add("onchange", "javascript: alert('me :)');")
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Test Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:RadioButtonList runat="server" ID="rbl"
RepeatDirection="Horizontal">
<asp:ListItem Value="1" Text="1" ></asp:ListItem>
<asp:ListItem Value="2" Text="2" ></asp:ListItem>
<asp:ListItem Value="3" Text="3" ></asp:ListItem>
</asp:RadioButtonList>
</form>
</body>
</html>

-----------------------------------------

Jun 12 '06 #4
>> For one thing, your script is incorrect. You can remove the "javascript:"
portion.

nop...

You are wrong.

1st we need to supply the language, like if you wanna print the page you
scecified

<a href="javascript: window.print();" >

and not only window.print(); ...

thans a W3C thing!

and secondly, even if I delete it still doesn't work :-(

--

Bruno Alexandre
(a Portuguese in Københanv, Danmark)


Not quite (as I see it):
A "href" usually has a URL in it, so it needs to be told that it
shouldn't redirect the browser to some URL, but execute a script
instead.
An "onclick" (onchange, onmouseover, onkeyup and other "on*"
attributes) doesn't redirect by itself, it is *designed* to execute a
script. That's why you don't need to tell it that it is javascript.

so :
<a href="javascript:alert('href')" onclick="alert('onclick')">X</a>
Hans Kesting
Jun 12 '06 #5
Bruno Alexandre wrote:
nop...

You are wrong.

1st we need to supply the language, like if you wanna print the page you
scecified

<a href="javascript: window.print();" >

and not only window.print(); ...

thans a W3C thing!
and secondly, even if I delete it still doesn't work :-(

Have a look:

http://validator.w3.org/check?ss=1&v....net/test.aspx
Jun 12 '06 #6
got it...
but still, my problem remains...

but I follow the link that Ray sent and I found that the RadioList is
compiled as an SPAN tag, so that's why the JS didn't work, because onChange
is not valid under a span tag

from this:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
rbl.Attributes.Add("onChange", "alert('me :)');")
End Sub

I changed to this:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Dim i As Integer
For i = 0 To rbl.Items.Count - 1
rbl.Items(i).Attributes.Add("onChange", "alert('me :)');")
Next
End Sub

and now it works fine :-)
--

Bruno Alexandre
(a Portuguese in Københanv, Danmark)
"Hans Kesting" <ne***********@spamgourmet.com> escreveu na mensagem
news:mn***********************@spamgourmet.com...
For one thing, your script is incorrect. You can remove the
"javascript:" portion.

nop...

You are wrong.

1st we need to supply the language, like if you wanna print the page you
scecified

<a href="javascript: window.print();" >

and not only window.print(); ...

thans a W3C thing!

and secondly, even if I delete it still doesn't work :-(

--

Bruno Alexandre
(a Portuguese in Københanv, Danmark)


Not quite (as I see it):
A "href" usually has a URL in it, so it needs to be told that it shouldn't
redirect the browser to some URL, but execute a script instead.
An "onclick" (onchange, onmouseover, onkeyup and other "on*" attributes)
doesn't redirect by itself, it is *designed* to execute a script. That's
why you don't need to tell it that it is javascript.

so :
<a href="javascript:alert('href')" onclick="alert('onclick')">X</a>
Hans Kesting

Jun 12 '06 #7
In IE onchange applies to INPUT TYPE=text, SELECT, and TEXTAREA.

Perhaps you need to use onpropertychange instead?

--
Greg Collins [Microsoft MVP]
Visit Brain Trove ( http://www.BrainTrove.com )
Jun 12 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Mattias Campe | last post by:
Hello, On http://student.ugent.be/astrid/bewoners.php I got the problem that I want Javascript to let my browser go to http://student.ugent.be/astrid/bewoners.php?beginAcjaar=2002 when I select...
4
by: rick | last post by:
The following basic script works fine in firefox by not in IE. Can anyone spot the problem? In IE I can only delete the first line but not the lines created by javascript. Also, look at the HTML...
4
by: Bart van Deenen | last post by:
Hi all I have a script where I dynamically create multiple inputs and selects from a script. The inputs and selects must have an associated onchange handler. I have the script working fine on...
5
by: Pascal Batzli Jr | last post by:
Hello, I have a strange situation happening on the code below. When I first load the page, as I change any of the three combo boxes I have created, the onchange event is fired and the form should...
3
by: jab3 | last post by:
Hello. I"m new to this group, and to JavaScript in general, so please forgive me if I breach local etiquette. I'm trying to implement some client-side 'dynamic' validation on a form. I'm having...
4
by: David McNerney | last post by:
Would anyone be able to tell me why I get an error in FireFox 1.5.0.1 for MacOSX when I type some text and hit Enter in the following form: <html> <body> <form action="http://example.com"...
10
by: david.bercot | last post by:
Hi, I have a big problem with a simple event : onchange !!! If I write this page : <html> <body> <form id="vu"> <input id="var01" name="var01" size="5" onchange="return false;"/> </form>...
7
by: Tim Slattery | last post by:
I'm trying to handle the onChange event in an <input type="file"> element. In IE, there's no problem: the event fires when a file in the "open" box is doubleclicked, or the "Open" button in the box...
21
by: Leena P | last post by:
i want to basically take some information for the product and let the user enter the the material required to make this product 1.first page test.php which takes product code and displays...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.