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

x
  • 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.
0
shiny
Asked:
shiny
1 Solution
 
sajuksCommented:
//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;
}
</script>
<table name="myTable" border="1">
<tr name="TheRow">
  <td id="TheCell">My cool text</td>
</tr>
<tr>
  <td>Another Text</td>
</tr>
</table>

<a href="javascript:chng('TheCell', 'New text')">change</a>
0
 
COBOLdinosaurCommented:
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>

Cd&
0

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