473,387 Members | 1,791 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,387 software developers and data experts.

Netscape 7.1 getElementById Error

Hi,

I have a javascript function which uses the method
document.getElementById.

I'm using it to decide whether a checkbox has been ticked or not. This
decision is encoded in an if statement with the condtion being
if (document.getElementById(checkboxtoupdate).value ==1)
/* The Code */

function set(object)
{
var checkboxtoupdate = object.value;

if (document.getElementById(checkboxtoupdate).value ==1)
document.getElementById(checkboxtoupdate).value = 0;
else
document.getElementById(checkboxtoupdate).value = 1;
}

The "object" accesses a html tag which has an value attribute e.g
value="7400"

However Netscape Navigator 7.1 does not seem to recognise
"document.getElementById(checkboxtoupdate).val ue"
and reports an error that
document.getElementById(checkboxtoupdate).value has no properties.

But Internet Explorer has no problem with this at all.

Is there another way to do this so as to be recognised by Netscape
7.1?
Jul 23 '05 #1
7 1330
On 7 Apr 2004 02:30:10 -0700, Gerry wrote:

[cut]
function set(object)
{
var checkboxtoupdate = object.value;

if (document.getElementById(checkboxtoupdate).value ==1) [cut] The "object" accesses a html tag which has an value attribute e.g
value="7400"

However Netscape Navigator 7.1 does not seem to recognise
"document.getElementById(checkboxtoupdate).val ue"
and reports an error that
document.getElementById(checkboxtoupdate).value has no properties.
It's right.
But Internet Explorer has no problem with this at all.


The behavior of IE is wrong. Or better, it doesn't fit standards.

From W3C:

ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed
by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"),
colons (":"), and periods (".").

--
C'ya,
ZER0 :: coder.gfxer.webDesigner();

Deformazione professionale è:
Quando in ascensore senti la ragazza accanto che tira fuori il cellulare,
e ti volti per capire se e' un modello sul quale puoi sviluppare in J2ME.
Jul 23 '05 #2


Gerry wrote:

I have a javascript function which uses the method
document.getElementById.

I'm using it to decide whether a checkbox has been ticked or not. This
decision is encoded in an if statement with the condtion being
if (document.getElementById(checkboxtoupdate).value ==1)
/* The Code */

function set(object)
{
var checkboxtoupdate = object.value;

if (document.getElementById(checkboxtoupdate).value ==1)
document.getElementById(checkboxtoupdate).value = 0;
else
document.getElementById(checkboxtoupdate).value = 1;
}

The "object" accesses a html tag which has an value attribute e.g
value="7400"


Is there any element in the page that has
<tagname id="7400">
?? I guess you don't have one but only
<tagname name="7400">
--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 23 '05 #3
Ivo
"Gerry" wrote
I'm using it to decide whether a checkbox has been ticked or not.
There is a word for that in javascript: checked. It is an ordinary
read/write property of any element that can be ticked and unticked. For
example this line
if(obj.checked==true) obj.checked= false
would see whether the object "obj" is currently ticked, and if so, untick
it.
function set(object)
{
var checkboxtoupdate = object.value;
So checkboxtoupdate is a value. Fine.
if (document.getElementById(checkboxtoupdate).value ==1)
So checkboxtoupdate not only *is* but also *has* a value of its own. Eh? Did
you not mean:
if (document.getElementById(object).value ==1)
document.getElementById(checkboxtoupdate).value = 0;
else
document.getElementById(checkboxtoupdate).value = 1;
}

The "object" accesses a html tag which has an value attribute e.g
value="7400"
That would be the checkboxtoupdate variable then.
However Netscape Navigator 7.1 does not seem to recognise
"document.getElementById(checkboxtoupdate).val ue"
and reports an error that
document.getElementById(checkboxtoupdate).value has no properties.

But Internet Explorer has no problem with this at all. Is there another
way to do this so as to be recognised by Netscape 7.1?


No idea why this works in IE.
Ivo
Jul 23 '05 #4

I beleive your code should be

function set(object)
{
var checkboxtoupdate = object.value;

if (document.getElementById(checkboxtoupdate).checked ==true)
document.getElementById(checkboxtoupdate).checked = false;
else
document.getElementById(checkboxtoupdate).checked = true;
}
--
Andy

"Gerry" <ge************@mail.dcu.ie> wrote in message
news:10*************************@posting.google.co m...
Hi,

I have a javascript function which uses the method
document.getElementById.

I'm using it to decide whether a checkbox has been ticked or not. This
decision is encoded in an if statement with the condtion being
if (document.getElementById(checkboxtoupdate).value ==1)
/* The Code */

function set(object)
{
var checkboxtoupdate = object.value;

if (document.getElementById(checkboxtoupdate).value ==1)
document.getElementById(checkboxtoupdate).value = 0;
else
document.getElementById(checkboxtoupdate).value = 1;
}

The "object" accesses a html tag which has an value attribute e.g
value="7400"

However Netscape Navigator 7.1 does not seem to recognise
"document.getElementById(checkboxtoupdate).val ue"
and reports an error that
document.getElementById(checkboxtoupdate).value has no properties.

But Internet Explorer has no problem with this at all.

Is there another way to do this so as to be recognised by Netscape
7.1?
Jul 23 '05 #5
Andy wrote:
I beleive your code should be
You would believe wrong.
function set(object)
{
var checkboxtoupdate = object.value;

if (document.getElementById(checkboxtoupdate).checked ==true)
document.getElementById(checkboxtoupdate).checked = false;
else
document.getElementById(checkboxtoupdate).checked = true;
}


checkboxtoupdate is a value of an element, as such, it has no "checked"
property.

And all of it is totally dependent on how object gets passed.

set(this.value);
set(this);
set('objectName);

And without knowing how set is called, and how object is passed, its
anybody's guess as to the problem.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/
Jul 23 '05 #6
Hi again,

Thanks for your replys,
checkboxtoupdate is a value of an element, as such, it has no "checked"
property.

And all of it is totally dependent on how object gets passed.

set(this.value);
set(this);
set('objectName);

The object gets passed like this (in the webpage that is)
OnClick="parent.videoDetailSubmit.set(this)"

The full tag is as below.

The id is a different number for each checkbox.

<input type="checkbox" name="tom" id="{keyFrame/frame}"
value="{startTime}" OnClick="parent.videoDetailSubmit.set(this)"</input>
a real example of the values for this:
<input OnClick="parent.videoDetailSubmit.set(this)" value="7400"
id="366" name="tom" type="checkbox">

In my code though i'm using the value attribute ,which 99.9% of the
time is unique but,in theory, it could be the same value for both
checkboxes, but when I try and use the unique "id" value , neither IE
or Netscape can seem to pick up on this with getElementById(object.id)
Why ever this happens I dont know.
Gerry.

Randy Webb <hi************@aol.com> wrote in message news:<da********************@comcast.com>... Andy wrote:
I beleive your code should be


You would believe wrong.
function set(object)
{
var checkboxtoupdate = object.value;

if (document.getElementById(checkboxtoupdate).checked ==true)
document.getElementById(checkboxtoupdate).checked = false;
else
document.getElementById(checkboxtoupdate).checked = true;
}


checkboxtoupdate is a value of an element, as such, it has no "checked"
property.

And all of it is totally dependent on how object gets passed.

set(this.value);
set(this);
set('objectName);

And without knowing how set is called, and how object is passed, its
anybody's guess as to the problem.

Jul 23 '05 #7
On 8 Apr 2004 01:43:39 -0700, Gerry <ge************@mail.dcu.ie> wrote:
The object gets passed like this (in the webpage that is)
OnClick="parent.videoDetailSubmit.set(this)"

The full tag is as below.

The id is a different number for each checkbox.

<input type="checkbox" name="tom" id="{keyFrame/frame}"
value="{startTime}" OnClick="parent.videoDetailSubmit.set(this)">
</input>
INPUT elements do not, and cannot, have closing tags.

HTML: <input ...>
XHTML: <input ... />
a real example of the values for this:
<input OnClick="parent.videoDetailSubmit.set(this)" value="7400"
id="366" name="tom" type="checkbox">

In my code though i'm using the value attribute ,which 99.9% of the
time is unique but,in theory, it could be the same value for both
checkboxes, but when I try and use the unique "id" value , neither IE
or Netscape can seem to pick up on this with getElementById(object.id)
Why ever this happens I dont know.


First, read ZER0's post; id values are illegal.

Second, why would you want to perform

document.getElementById( object.id );

where object is an element reference? It will simply return object, and so
the call will just be an expensive waste of time.

You've now managed to confuse the issue in my mind. First, it appeared
that the value of a control represented the id of another, and you wanted
to get a reference to that control through:

document.getElementById( object.value );

Now it appears that you want a reference to element passed, which you
already have in "object".

Mike
Please, don't top-post.

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 23 '05 #8

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

Similar topics

7
by: Scott | last post by:
Hello All, I've been reading all of the various issues with Iframes in netscape. I have tried all of the various fixes posted, and have even implemented both an iframe and ilayer. My problem is...
10
by: Todd Cary | last post by:
This JavaScript slideshow works with Netwcape; not IE. Is there some obvious that is missing? http://209.204.172.137/slideshow/slideshow.html Todd
7
by: Rick | last post by:
This script works with IE but not Netscape anyone know what I am doing wrong? If so could you help me out I am at a lost? Thanks in advance. The error is as follow Error: pen0 has no...
4
by: lawrence | last post by:
Can anyone tell me why this code works in Netscape 7.1 but not in IE??? <SCRIPT type='text/javascript'> function makeVisible(nameOfDiv) {...
26
by: Roger Desparois | last post by:
Hi, I need help : I found the simplest and most precise way to open and close submenu layers. it works perfectly with IE, but for some odd reason NS won't recognize it. Can anyone tell me why...
2
by: BTHOMASinOHIO | last post by:
In IE, this runs fine, but in Netscape, it doesn't error, but just doesn't run. WHY?!?! (in the Page Code Behind) BODY1.Attributes.Add("onLoad", "DisplayData();") (in the HTML of the...
5
by: zaw | last post by:
Hi I am working on implementing this script to shopping cart. Basically, it copies fill the shipping address from billing automatically. I believe one or more syntax is not netscape compatible....
3
by: Ron M | last post by:
I am sure this is a simple issue, but being a beginner I am struggling. In the following js function I am attempting to make sure no numbers are within "name" controls. I want to pass the text...
8
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I detect Opera/Netscape/IE? ----------------------------------------------------------------------- The...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...

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.