Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap

Q703 How can I change the contents of a table cell when the mouse moves over an image in a form?

You are here: irt.org | FAQ | DHTML | Q703 [ previous next ]

Its a bit messy, but it can be done:


<SCRIPT LANGUAGE="JavaScript"><!--
rowArray = new Array();
rowArray[0] = '<FORM><A HREF="#" onMouseOver="refreshTable(1)" onMouseOut="refreshTable(0)"><IMG SRC="image1.gif" WIDTH="100" HEIGHT="20" BORDER="0"></A>' +
              '<A HREF="#" onMouseOver="refreshTable(2)" onMouseOut="refreshTable(0)"><IMG SRC="image2.gif" WIDTH="100" HEIGHT="20" BORDER="0"></A><\/FORM>';
rowArray[1] = 'This is some text for row 1';
rowArray[2] = 'This is some text for row 2';

function refreshTable(x) {
    var output = '<TABLE><TR><TD>' + rowArray[0] + '<\/TD><\/TR>';
    if (x != 0)
        output += '<TR><TD>' + rowArray[x] + '<\/TD><\/TR>';
    output += '<\/TABLE>';

    if (document.all)
        document.all('myTable').innerHTML = output;
    else if (document.layers) {


<BODY onLoad="refreshTable(0)">

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


©2018 Martin Webb