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

item not defined using Mozilla?

LRW
I have a Javascript that makes a tablerow visible ot invisible, that
works fine in InternetExplorer, but in Mozilla it's unresponsive and I
get the following Javascript Console error:
Error: itemeditrow is not defined
Source File: editform.php
Line: 45

Below is the Javascript, and a section of the HTML for that tablerow.

I don't get it. It looks defined to me. What am I missing?

Thanks for any help!
Liam

<!-- Begin
function makeItemEditVis()
{
itemeditrow.style.visibility = 'visible';
itemeditrow2.style.visibility = 'visible';
}
// End -->

<tr class="label" id="itemeditrow" style="visibility:hidden"><td
colspan="3" class="labelBlue" bgcolor=#E6EDF5>item #:
etc....
Jul 23 '05 #1
6 3592
de**@celticbear.com (LRW) writes:
I have a Javascript that makes a tablerow visible ot invisible, that
works fine in InternetExplorer, but in Mozilla it's unresponsive and I
get the following Javascript Console error:
Error: itemeditrow is not defined ....
itemeditrow.style.visibility = 'visible';
itemeditrow2.style.visibility = 'visible'; .... <tr class="label" id="itemeditrow" style="visibility:hidden"><td


Check <URL:http://jibbering.com/faq/#FAQ4_41>

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #2
LRW wrote:

Thanks for any help!
Liam

<!-- Begin
function makeItemEditVis()
{
itemeditrow.style.visibility = 'visible';
The reference to itemitrow is wrong. Use the dom heirarchy to reference it.
Mick itemeditrow2.style.visibility = 'visible';
}
// End -->

<tr class="label" id="itemeditrow" style="visibility:hidden"><td
colspan="3" class="labelBlue" bgcolor=#E6EDF5>item #:
etc....

Jul 23 '05 #3
LRW
Lasse Reichstein Nielsen <lr*@hotpop.com> wrote in message news:<zn**********@hotpop.com>...
de**@celticbear.com (LRW) writes:
I have a Javascript that makes a tablerow visible ot invisible, that
works fine in InternetExplorer, but in Mozilla it's unresponsive and I
get the following Javascript Console error:
Error: itemeditrow is not defined

...
itemeditrow.style.visibility = 'visible';
itemeditrow2.style.visibility = 'visible';

...
<tr class="label" id="itemeditrow" style="visibility:hidden"><td


Check <URL:http://jibbering.com/faq/#FAQ4_41>


Thanks for the reply!
So, odd. I changed the lines to:
document.form1.itemeditrow.style.visibility = 'visible';
document.form1.itemeditrow2.style.visibility = 'visible';
And I no longer get the "not defined" error, except, now not only does
it not work in Mozilla but also stopped working in IE.

And the form tag has name="form1". Then I added id="form1" but no
change.

I have no idea if this is related, but in the Mozilla JavaScript
Console I'm also getting the error:

"document.form1.itemeditrow has no properties"
It's refering to the line that has:
document.form1.itemeditrow.style.display = 'block';

Isn't 'block' a property for "display"?

=P
Thanks for the help!
Liam
Jul 23 '05 #4
On 14 Sep 2004 08:16:48 -0700, LRW <de**@celticbear.com> wrote:

[snip]
Thanks for the reply!
So, odd. I changed the lines to:
document.form1.itemeditrow.style.visibility = 'visible';
document.form1.itemeditrow2.style.visibility = 'visible';
And I no longer get the "not defined" error, except, now not only does
it not work in Mozilla but also stopped working in IE.
Can you answer this question: How does placing a table row in a form allow
you to access that row as if it were a form control?

Logic alone should tell you that it doesn't. There is no correlation
between form controls and table components. It appears that you missed the
point of the link Lasse gave you. You need to access the row using the id,
but in a cross-browser fashion.

if(document.getElementById) {
var itmRow = document.getElementById('itemeditrow');

if(itmRow && itmRow.style) {
itmRow.style.display = 'block';
}
}

[snip]
I have no idea if this is related, but in the Mozilla JavaScript
Console I'm also getting the error:

"document.form1.itemeditrow has no properties"
It's refering to the line that has:
document.form1.itemeditrow.style.display = 'block';

Isn't 'block' a property for "display"?


Yes, it is, but that's not the error. Because the form doesn't contain the
row, document.form1.itemeditrow evaluates to undefined. Obviously, you
can't access a property that doesn't exist, and that's why Mozilla says
that document.form1.itemeditrow has no properties.

Hope that helps,
Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #5
LRW wrote:
Lasse Reichstein Nielsen <lr*@hotpop.com> wrote in message
news:<zn**********@hotpop.com>...
Please do not write attribution novels.
[...]
Please trim your quotes.
So, odd. I changed the lines to:
document.form1.itemeditrow.style.visibility = 'visible';
document.form1.itemeditrow2.style.visibility = 'visible';
And I no longer get the "not defined" error, except, now not only does
it not work in Mozilla but also stopped working in IE.
There is no (form) element with ID "itemeditrow2" in your document.
And the form tag has name="form1".
It is not the "form tag", there is no such thing. You mean the "form"
element and have the initial value of the "name" attribute of that element
replaced with the value "form1" by including an attribute-value pair in
its start tag (<form>).
Then I added id="form1" but no
change.
Of course not.
I have no idea if this is related, but in the Mozilla JavaScript
Console I'm also getting the error:

"document.form1.itemeditrow has no properties"
It is very much related. This is because null/undefined has no properties.
It's refering to the line that has:
document.form1.itemeditrow.style.display = 'block';

Isn't 'block' a property for "display"?


No, `display' is a (CSS) property and `block' is a possible value for it.

However, if you refer to the form and then want to refer to an element of
the form by its ID, you must use the square bracket property accessor and
the "elements" collection. You should also use the "forms" collection:

document.forms['form1'].elements['itemeditrow'].style.display = 'block';

However, you don't want to refer to a form element, i.e. "input" and the
like, so the target element is _not_ part of the "elements" collection of
the HTMLFormElement object. The following should work:

<head>
<title>...</title>
...
<script type="text/javascript">
function makeItemEditVis()
{
var t;
if ((t = typeof document.getElementById) == "function"
|| (t == "object" && document.getElementById))
{
for (var i = arguments.length; i--;)
{
var o = document.getElementById(arguments[i]);
if (o
&& typeof o.style != "undefined"
&& typeof o.style.visibility != "undefined")
{
o.style.visibility =*'visible';
}
}
}
}
</script>

<style type="text/css">
.labelBlue {
background-color:#ccf;
color:#000;
}
</style>
</head>

<body>
<form action="...">
<table>
<tr class="label" id="itemeditrow" style="visibility:hidden">
<td colspan="3" class="labelBlue">item #:</td>
...
</tr>
...
</table>
...
<script type="text/javascript">
document.write(
'<input type="button"'
+ ' onclick="makeItemEditVis(\'itemeditrow\','
+ ' \'itemeditrow2\');">');
</script>
...
</form>

As you can see, do not mix CSS and formatting attributes, and use
secure colors only; also remove the SGML Comment Opener and Closer,
they are obsolete (even though it is described differently in the
HTML 4.01 Specification).
HTH

PointedEars
--
Management dictated that no bugs should ever make it to production. We no
longer put code in production.
Jul 23 '05 #6
JRS: In article <37*****************@PointedEars.de>, dated Mon, 20 Sep
2004 19:41:55, seen in news:comp.lang.javascript, Thomas 'PointedEars'
Lahn <Po*********@web.de> posted :
LRW wrote:
Lasse Reichstein Nielsen <lr*@hotpop.com> wrote in message
news:<zn**********@hotpop.com>...


Please do not write attribution novels.


It is permissible for Lahn's home hierarchy, news:de.*, to hold such
views. But, like the events of 1939-09-01 and 1940-04-09, it is now
internationally considered to be a Mistake.

Present Usenet thinking encourages proper attributions; see Usefor work-
in-progress at
http://www.ietf.org/internet-drafts/...-useage-00.txt
http://www.ietf.org/internet-drafts/...article-13.txt
An informative attribution would have made it clear that the idiot
savant child Lahn is, once more, contributing to an ancient thread.
<FAQENTRY>
The FAQ should cite the above, or successor, documents; and perhaps also
that in sig line 2, which is so widely useful.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME ©
Web <URL:http://www.uwasa.fi/~ts/http/tsfaq.html> -> Timo Salmi: Usenet Q&A.
Web <URL:http://www.merlyn.demon.co.uk/news-use.htm> : about usage of News.
No Encoding. Quotes before replies. Snip well. Write clearly. Don't Mail News.
Jul 23 '05 #7

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

Similar topics

2
by: Peter | last post by:
Hello, First of all, sorry for all the code. I don't know how to explain my problem without it. I have a javascript function which can build a webpage dynamically. A striped down version of...
17
by: Colin Cogle | last post by:
------- Line 47, column 8: there is no attribute "id" <DIV id="LeftNavigation" style="position:absolute; left:8px; top:6px; width:200p ------- Line 47, column 31: there is no attribute "style"...
8
by: dp | last post by:
Is there anyway to have the bullet color of a <li> be a different color than the text without using an image? dp
6
by: Steven T. Hatton | last post by:
As I was reading through some of the stuff in the Standard, I started to wonder if there might be reason to define classes in response to runtime conditions, say, to match some kind of new data...
3
by: Jim Ley | last post by:
Hi, It seems the mozilla guys have chosen another (almost certainly poor choice in my initial thoughts) of having document.all evaluate to false, but document.all catch the chicken event - also...
2
by: Bernhard Georg Enders | last post by:
Hi! Everything works fine with Opera and IE, but not with Mozilla 1.7.3 and Firefox 1.0 PR. When I call a function previously defined inside another function I've got "function is not defined"....
15
by: prabhdeep | last post by:
Hi, Can somebody explain, why in following code, i get "event not defined" error funcTest(sMenu) { doument.getElementById('id1').addEventListener('mousedown', function(){ click(sMenu,...
8
by: nektir | last post by:
I have an external js file to validate a form and it works in IE and Opera, but not Mozilla Firefox. In Mozilla Firefox, the javascript console sasys "SearchForm" is not defined in the second...
1
by: jodleren | last post by:
Hi I tried getElementById, it works in IE, but how I find items on a form properly? I can write a small for myself, but is there a function to find <inputitems on a form? That is, standard JS...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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.