LRW said:
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 ( said:
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
);
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