The following input checkbox onclick via DOM is not working on IE7, FF, or
WebKit, but is working on Opera for some strange reason. http://www.aarongray.org/Test/JavaScript/checkbox.html
Here's the code :-
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<script type="text/javascript" src="LibJS.js"> </script>
</head>
<body onLoad="init()" >
<script>
use( LibJS.HTML)
function init()
{
test = document.create Element( "INPUT")
test.type = "checkbox"
test.checked = true
test.onClick = "alert( 'test = ' + this.checked)"
// test.setAttribu te( "onClick", "alert( 'test = ' + this.checked)")
document.body.a ppendChild( test)
}
</script>
</body>
</html>
Hope I have not missed something too silly.
Many thanks in advance,
Aaron 4 7177
On Oct 31, 2:35 pm, Aaron Gray wrote:
The following input checkbox onclick via DOM is not
working on IE7, FF, or WebKit, but is working on Opera
for some strange reason.
<snip>
function init()
{
test = document.create Element( "INPUT")
test.type = "checkbox"
test.checked = true
test.onClick = "alert( 'test = ' + this.checked)"
<snip>
Hope I have not missed something too silly.
In case sensitive javascript the property name to which you should be
assigning is 'onclick' (all lower case), and the value you should be
assigning is a reference to a function object not a string primitive.
Richard.
"Richard Cornford" <Ri************ **@googlemail.c omwrote in message
news:b2******** *************** ***********@s9g 2000prm.googleg roups.com...
On Oct 31, 2:35 pm, Aaron Gray wrote:
>The following input checkbox onclick via DOM is not working on IE7, FF, or WebKit, but is working on Opera for some strange reason.
<snip>
>function init() { test = document.create Element( "INPUT") test.type = "checkbox" test.checked = true test.onClick = "alert( 'test = ' + this.checked)"
<snip>
>Hope I have not missed something too silly.
In case sensitive javascript the property name to which you should be
assigning is 'onclick' (all lower case), and the value you should be
assigning is a reference to a function object not a string primitive.
"function object not a string primitive" thats the one, silly, silly me !
Have not done some JavaScript for a couple of weeks, amazing how quickly my
brain chucks things out.
Aaron
Le 10/31/08 4:32 PM, Aaron Gray a écrit :
"Richard Cornford" <Ri************ **@googlemail.c omwrote in message
news:b2******** *************** ***********@s9g 2000prm.googleg roups.com...
>On Oct 31, 2:35 pm, Aaron Gray wrote:
>>The following input checkbox onclick via DOM is not working on IE7, FF, or WebKit, but is working on Opera for some strange reason.
<snip>
>>function init() { test = document.create Element( "INPUT") test.type = "checkbox" test.checked = true test.onClick = "alert( 'test = ' + this.checked)"
test.onclick = function() { alert('test = ' + this.checked); };
}
Have not done some JavaScript for a couple of weeks, amazing how quickly my
brain chucks things out.
--
sm
"SAM" <st************ *********@wanad oo.fr.invalidwr ote in message
news:49******** *************@n ews.orange.fr.. .
Le 10/31/08 4:32 PM, Aaron Gray a écrit :
>"Richard Cornford" <Ri************ **@googlemail.c omwrote in message news:b2******* *************** ************@s9 g2000prm.google groups.com...
>>On Oct 31, 2:35 pm, Aaron Gray wrote: The following input checkbox onclick via DOM is not working on IE7, FF, or WebKit, but is working on Opera for some strange reason. <snip> function init() { test = document.create Element( "INPUT") test.type = "checkbox" test.checked = true test.onClick = "alert( 'test = ' + this.checked)"
test.onclick = function() { alert('test = ' + this.checked); };
}
>Have not done some JavaScript for a couple of weeks, amazing how quickly my brain chucks things out.
Yes, thanks Sam, I now have everything working fine now :)
Aaron This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: lehmann |
last post by:
Hello,
I discovered that in a form with checkboxes input, if the checkboxe is
not checked, not value is sent in my request by the browser (at least
IE, I think it is ok in NS).
But I my application I need to get the input even if it is not checked
(my form is dynamic and I distinguish the cases: input exists and is
cheched / input exists ans is not checked / input doesn't exists)
I know I could use another input such as textfield, but I...
|
by: F. Da Costa |
last post by:
Hi,
Does the following indeed imply that this event is NOT called when an <input type="checkbox" is toggled?
This would thus imply the usage of the onClick handler instead (assuming an action needs to be invoked on check/ uncheck).
W3C Recomendation:
18 Scripts
onselect = script
The onselect event occurs when a user selects some text in a text field. This attribute may be used with the INPUT
|
by: Jim Tome |
last post by:
Hi,
I am trying to change and pass the value of a hidden input type on a
form tag to a cgi processing script based on the value of a checkbox
within the form:
function CheckBoxes () {
if (document.MyForm.CheckBox1.checked) {
document.MyForm.recipient.value = "2";
document.MyForm.submit();
|
by: Randell D. |
last post by:
Folks,
I have a form called "ourTestForm".
Its a test form - nothing special - it contains five input tags - they
are named one, two, three, four and five.
The input tags are of type text,text,radio,checkbox and select.
When I run the following code, it correctly reports "text" (for input
|
by: spolsky |
last post by:
try the the following code with Opera 9.01 (Windows). when clicked
slightly faster than normal clicking, the toggler checkbox and other
checkboxes displays differently although event method works fine to
update the checkboxes. there is not any problem with IE 6 or FireFox
1.5. also, i used the double click event method to see if its the
source but that does not help even. Opera 9.01 seems to be slow at
updating checkboxes visually. am i...
| |
by: oopaevah |
last post by:
I want to have a separate button which invokes the "browse" button on
an input type=file. In internet explorer the following code works ok,
in firefox nothing happens.
All I do is call click() for the input control.
Do you know how to make this work in firefox?
Thanks
|
by: Diogenes |
last post by:
Hi All;
I, like others, have been frustrated with designing
forms that look and flow the same in both IE and Firefox.
They simply did not scale the same.
I have discovered, to my chagrin, that IE7 does not seem
to offer any way to control the font size of a text input
element.
|
by: Aaron Gray |
last post by:
I am finding that <input type="checkbox" onchange="alert('test')"></input>
does not seem to work properly on IE7.
http://www.aarongray.org/Test/JavaScript/checkbox.html
It works fine on FF and Google Chrome.
Any suggestions ?
Many thanks in advance,
|
by: sydneycan |
last post by:
Hi everyone. First time I'm posting something, so far I've been able to google it out but this time no luck so far...
I have a html input checkbox on my page
From the javascript 'switchlayers' in onclick() event I'm raising a callback event on the server side.
within this callback I want to check the status of the checkbox (checked/unchecked) and I want to avoid sending this status in a callback message.
the problem is that even if I'm...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| | |