/    Sign up×
Community /Pin to ProfileBookmark

Tables And Anchors

I would one go about creating anchors based the contents of a cell of a table for an entire column?

I know I am going to have to use a counting loop but I was wondering how this is going to work… I fear I might have to use DOM but I am DOM illiterate

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@phpnoviceJun 21.2006 — Technically speaking, there ain't no way to gain access to an HTML table [B][I]*[U]without[/U]*[/I][/B] using the DOM. ? So, what kind of anchors were you wanting to create? Also, it would, of course, be infinitely better if these anchors were created before-hand. Is there a particular reason why they can't be done that way?
Copy linkTweet thisAlerts:
@derek_laurauthorJun 21.2006 — well, its very large table, as in over 750 rows...

serval columns

x, y , z

the column z is the ID for the information on the row,

now if I have a script that takes the id number from the column z, I can search it using anchors and go to that particular part of the page
Copy linkTweet thisAlerts:
@phpnoviceJun 21.2006 — Give the table an id. The following code presumes that the ID information you're looking for starts with row 2, is in column 3, and is the only data in the cell:

var s, tbl = document.getElementById("tableID");

var c = 2, r, rlen = tbl.rows.length;

for(r=1; r<rlen; ++r) {

s = tbl.rows[r].cells[c].firstChild.data;

tbl.rows[r].cells[c].innerHTML = '<a name="_' + s + '"></a>' + s;

}

The above inserts an anchor in front of the ID information. The anchor [B]name[/B] is the ID information with a single underscore in front of it.
Copy linkTweet thisAlerts:
@derek_laurauthorJun 21.2006 — thanks phpnovice, its just this parent.node child note first child stuff that confuses me, I am still living in the dark ages and use note pad to work with my web stuff
Copy linkTweet thisAlerts:
@phpnoviceJun 21.2006 — Notepad is what I use here at work. At home I use FrontPage -- with built-in Script Editor, Script Debugger, context coloring, and context-sensitive Help. ?

Cheers.
×

Success!

Help @derek_laur spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...