[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1372
  • Last Modified:

Hyperlink target to a Cell of a Table

Is it possible, just using HTML (or even a simple java script) to have the target of a hyperlink be a cell in a table?  My goal is to have the hyperlink change the contents of a cell upon being clicked.
1 Solution
//try this simple example by Antithesis. The key here is the getElementById function.
//Once you give each cell an id you could reference it in whatev'r way you want
<script language="javascript">
function getobj(g_elm)  {
    if (document.all) return document.all[g_elm];
    if (document.layers) return document.layers[g_elm];
    if (!document.all && document.getElementById) return document.getElementById(g_elm);
function chng(c_el, c_tx)  {
    getobj(c_el).innerHTML = c_tx;
<table name="myTable" border="1">
<tr name="TheRow">
  <td id="TheCell">My cool text</td>
  <td>Another Text</td>

<a href="javascript:chng('TheCell', 'New text')">change</a>
Three options:

1.  If you just want to target teh cell to insert some text or an image then you bring them in with the original page in a hidden layer and then then swap the nodes from the onclick event of the link.  Using the onclick event means Jaascript must be enable.

2.  Use XMLHTTP with a lot of scripting.  This will equire not just JavaScript support, but for IE will also requie active x support.

3.  Put an iframe in the cell and target that.  Pure HTML.

3 is my preferred option and would work like this:

<td><iframe name="targetF" src=""></iframe></td>

The link would look like:
<a href="blah.html" target="targetF">click for blah</a>


Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now