Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q732 Is it possible to name an individual cell in a table?

You are here: irt.org | FAQ | JavaScript | Table | Q732 [ previous next ]

IIRC you can't name an individual table cell, or you can't in Netscape Navigator 4, you might in Internet Explorer 4. The browser object model is particulary weak when it comes to tables.

If you want a cross browser solution then you'll need to use layers and position them over the table yourself.

<HTML>
<HEAD>

<STYLE type="text/css"><!--
.answers { text-decoration:none; color:black; }
//--></STYLE>

<SCRIPT LANGUAGE="JavaScript"><!--
function showTable() {
    var output = '<TABLE BORDER="1" WIDTH="500">' +
                 '<TR><TD>Is black == white?<\/TD><\/TR>' +
                 '<TR><TD><A HREF="javascript:wrong()" CLASS="answers" onMouseover="self.status=\'\';return true">Yes</A><\/TD><\/TR>' +
                 '<TR><TD><A HREF="javascript:correct()" CLASS="answers" onMouseover="self.status=\'\';return true">No</A><\/TD><\/TR>' +
                 '<\/TABLE>';

    if (document.all)
        document.all('myTable').innerHTML = output;
    else if (document.layers) {
        document.layers['myTable'].document.open();
        document.layers['myTable'].document.writeln(output);
        document.layers['myTable'].document.close();
    }
}

function wrong() { alert('Wrong'); }

function correct() { alert('Correct'); }

if (document.all || document.layers)
     document.write('<FORM>Reveal Table: <INPUT TYPE="BUTTON" VALUE="Reveal" onClick="showTable()"><\/FORM>');
//--></SCRIPT>

</HEAD>

<BODY>

<SPAN ID="myTable" STYLE="position:absolute"></SPAN>

</BODY>
</HTML>

Feedback on 'Q732 Is it possible to name an individual cell in a table?'

©2018 Martin Webb