Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Clickable Table Cells

Status
Not open for further replies.

JAG7

Technical User
Nov 1, 2001
4
US
Currently, I'm able to make a table cell &quot;linkable&quot; based on the href attribute in an <a> tag (the way Hotmail used to). IE uses the scripting...

function mClk(src)
{
if(event.srcElement.tagName == 'TD')
{
src.children.tags('a')[0].click();
}
}

...and naturally, this only works in IE 4+. Using the 'childNodes' in DOM1, or any other tags, can I get a similar effect in NN6? I think NN4 is out-of-the-question.

jG
 
JAG7,

i havent really researched it much, but i found this nifty little page:

<html>
<!- Written by Keith Swerling at <!- Clickable Table Regions, as seen on <!- Help me make it better KeithS@TopiXonline.com
<head>
<SCRIPT LANGUAGE=&quot;javascript&quot;>
<!-- Hide

function tableOut(thiss) {
thiss.style.borderColor='white';
thiss.style.backgroundColor='white';
}

function tableOver(thiss) {
thiss.style.borderColor=&quot;#999999&quot;;
window.status=&quot;Click here for Details&quot;;
}

function roll(thiss) {
thiss.style.backgroundColor=&quot;yellow&quot;;
parent.location.href=('}

function details() {
window.status='Click here for Details';
}
</script>
</head>


<body>
Sorry I don't have more time for Verbage. I will try and write more. If you have questions that I can answer about this script, let me know. KeithS@TopiXonline.com.<br>
<br>
<TABLE border=0 CELLSPACING=0 cellpadding=0 valign=&quot;top&quot; width=300 STYLE=&quot;cursor: hand&quot; style=&quot;TABLE-LAYOUT:fixed;&quot; align=center>
<tr>
<td valign=&quot;TOP&quot; width=225>
<table border=0 cellspacing=0 width=100% style=&quot;border:2px solid white;TABLE-LAYOUT:fixed;&quot; onclick=roll(this) onMouseover=tableOver(this) onMouseout=tableOut(this) height=44>
<TR>
<td width=2></td>
<th width=44>
<a href=&quot;/cgi-bin/sgsc0101.exe?SRCCODE=WEKE007&FNM=04&GEN0=TV306&quot; title=&quot;Click here for Details&quot; onmouseover=&quot;details(); return true;&quot;><Img alt=&quot;Click here for Details&quot; SRC=&quot;/images/p2372T.JPG&quot; border=0 height=40 width=40></a>
</th>
<td width=1></td>
<th width=181 align=left>
<font face=&quot;Arial,Verdana,helvetica, ms fixed width&quot; size=1><a href=&quot;/cgi-bin/sgsc0101.exe?SRCCODE=WEKE007&FNM=04&GEN0=TV306&quot; title=&quot;Click here for Details&quot; onmouseover=&quot;details(); return true;&quot;>Planet TopiX Universal Remote</a> <b><nobr> - <font color=red>$24.95</nobr></b>
</th>
</TR>
</table>
</td>
</tr>
</table>
</body>
</html>


--i hope you can use it ;)


~ jsLove
 
Works very well, with one caveat...the URL in 'parent.location.href' is hard-coded. I need to find a way to get the href value in the <a> tag from the <td> tag, hence:

<td onClick=&quot;javascriptFunction&quot;>
<a href=&quot;something.html&quot;>
</td>

I'm thinking something like:

onClick=&quot;parent.location.href(this.firstChild);&quot;

...or something to that effect. Any ideas (and thanks for the tip!..I'll keep playing with it).
 
JAG7,

hmm, you mean you want the href to be variable?

....you might try:

<td onClick=&quot;YourFunction(something.html)&quot;>Click Here!</td>

....this way you can pass the url link to the function.

your function would be like:

YourFunction(UrlLink){
parent.location.href=(UrlLink);
}

...with whatever modifications you like of course ;)

...hope it helps
~ jsLove
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top