Harry Gould wrote:
[color=blue]
> To all,
>
> I'm a newbie here, so please bear with me.
>
> I develop web pages for a company intranet where Internet Explorer 6
> is the standard. Now I must develop a public internet website that is
> browser-agnostic (i.e., works with Netscape, version 4x,[/color]
Forget NS 4.x: whatever your code is, it will never work in that 6+ year
old browser. Its W3C DOM support is zero.
7x, etc). My[color=blue]
> question is this: I have about 10 table rows, each tagged with a class
> attribute (<tr class="billing" style="display:none">) that I wish to
> make visible or invisible in response to a checkbox click. For IE, I
> am calling this function:
>
> function showBillingInfo ( thisCheckbox, billingClass ) {
>
> var i;
> var billingRows = document.all.tags("TR");[/color]
If MSIE 6 is the standard, then
document.getElementById("idTable").rows will return a collection of all
rows of the table with the id attribute "idTable". Resorting to this way
of creating a working array of rows is supported by MSIE 5+,
Mozilla-based browsers, Opera 7.x, etc. and most W3C DOM1 compliant
browsers;
http://www.w3.org/TR/DOM-Level-2-HTM...tml#ID-6156016
One point on your code: it seems to me there is no need to assign a
class name to each rows in your code.
[color=blue]
> for ( i = 0; i < billingRows.length; i++ ) {
> if ( billingRows(i).className == billingClass ) {
> if ( thisCheckbox.checked == true ) {
> billingRows(i).style.display = "inline";[/color]
That looks suspicious. I wonder why this works under MSIE 6. I would
expect it to work only with
if (thisCheckbox.checked) {
billingRows[i].style.display = "block";
[color=blue]
> } else {
> billingRows(i).style.display = "none";
> }
> }
> }
> }
>
> This works fine in IE. Can anyone tell me what the comparable approach
> would be for Netscape browsers? I know how to test for specific
> browsers;[/color]
There is no need to detect browsers; only a need to verify the support
for attributes or methods by objects.
http://jibbering.com/faq/#FAQ4_26
what stumps me is the proper syntax for referring to[color=blue]
> document objects once a Netscape browser is detected.[/color]
NS 7.x and MSIE 6 and Opera 7.x and Mozilla 1.x share a large chunk of
the same [W3C DOM 2 HTML] way to access|manipulate|insert DOM nodes in a
document. Proprietary DOM attributes and methods are pointless,
irrelevant once a standard has been defined and agreed upon by involved
parties. And this is the case here.
I tried using[color=blue]
> "document.classes.billing.all.style.display = 'inline' " but that
> didn't work.
>
> Can anyone offer any working examples? What am I missing?
>
> Thank you.
>
>
> Harry Gould
> Philadelphia Newspapers Inc.
>
gouldh@phillynews.com[/color]
Here's one:
http://www10.brinkster.com/doctorunc...nCollapse.html
If your table(s) have border-collapse:collapse, then this might be
problematic in recent Mozilla-browsers. The code can be adjusted to work
for column groups and row groups too. For practical purposes, the
support for visibility: collapse is too weak right now to implement it.
The code could be improved a bit more by resorting to default display
value for <tr>.
DU