Board Logo

Using onclick instead of <A HREF=....
spw - 1/10/2006 at 03:17 AM

Just started using the products and while the documentation is sometimes a little cryptic, the product is great and the Forum is full of good ideas.. Here is my contribution (similar to another one but with more explanation).

I did not want to use embedded HTML as this mean that users would have to click on a specific column to activate a link. The onclick function works well as follows:

CONTENT.JS
----------------
var TABLE_CONTENT = [
["ac", "Allan", "Clarke", "Singer/composer", "The Hollies", "1998, July"], ... etc
// Note that column 0 contains a key - this is actually the src file without the ".html" extension

TEMPLATE.JS
-----------------
The following inserted (as you will see before and immediately after the TABLE_LOOK declaration:

// row click function for spawing data views - gets src from key value in col 0
function row_clck(marked_all, marked_one) {
window.location = marked_one+".html"; //adds .html extension
}

// structure that describes visual aspects of the table
var TABLE_LOOK = {

// select column zero for key value and pass with onclick function
'key': 0, // field column to use as 'marked_one'
'onclick': row_clck, // function to be called when a row is clicked// 0 - caption,


SIMPLE - and it WORKS SO WELL!!!!!!!


spw - 1/16/2006 at 06:45 AM

Follow-up coments: I am now using the same table in htree different sections of the site and using the onclick function each time to extract the key vale and add to it extensions that point to different files that suit the section of the site . For example in the main page I use the value to redirect users to an information page:

// onclick funtion for spawing links to interviews
function row_clck(marked_all, marked_one) {
window.location = "int_"+marked_one+".html";
}

In another section i point to a related graphic:

// onclick funtion for spawing links to interview graphics
function row_clck(marked_all, marked_one) {
window.location = "images/art_"+marked_one+".jpg";
}

And finally I also point to related sound files:

// onclick funtion for spawing links to sound bites
function row_clck(marked_all, marked_one) {
window.location = "audio/sb_"+marked_one+".mp3";
}

The secret is that there are THREE template.js files and each page points to "its own" template.js

VERY VERSATILE!


Softcomplex: http://www.softcomplex.com/
Back to forum: http://www.softcomplex.com/forum/