Just sharing this function i made,
this simple function will allow you to use:

[b]getElementById[/b]

[b]getElementsByTagName[/b]

[b]getElementsByClassName[/b]
in just one simple line
[color=#999999]____________________________________________________________[/color]
[b]FEATURES :[/b]

small file size, only 508 bytes

tested in Firefox3, IE6, IE7 and Opera9.51

easy to use

can handle infinite length of expression

helpful for newbies

and made by only me

[color=#999999]____________________________________________________________[/color]
[b]THE CODE:[/b]
[url=http://mark16.fileave.com/dom.js][img]http://i173.photobucket.com/albums/w76/myparis16/ss-1.jpg[/img][/url]
[color=#999999]____________________________________________________________[/color]
[b]HOW TO USE:[/b]
PARAMETERS: $(expression,parent);
[i]expression[/i]:
this is compose of [b]Id[/b], [b]ClassName[/b] or [b] TagName[/b] of a tag
separated by [b]SINGLE SPACE[/b]
sample: $('#0 table[0] .imgblock200[0] img[0]')
[color=#cccccc]________________________[/color]
[i]parent[/i](optional):
if parent is not declared the object ducument will be use
sample: $('table[0] .imgblock200[0] img[0]', $('#0'))
[color=#cccccc]________________________[/color]
For example
[img]http://i173.photobucket.com/albums/w76/myparis16/ss2-2.jpg[/img]
i want to get the message contains in the 3rd instance of className [b]data[/b] in my comments
which is "[i]salamat ng mrami.. ^^[/i]"
to get that you have to code this:
[quote]a = document.getElementById(18).getElementsByTagName('*');
b = 'data';
c = [];
for(i=0;i<a.length;i++){
d = a[[color=#000000]i[/color]].className.split(' ');
for(j=0;j<d.length;j++){
if(d[j]==b){
c.push(a[[color=#000000]i[/color]]);
break
}
}
}
c[2].getElementsByTagName('li')[2].innerHTML[/quote]
using my function
[quote]$('#18 .data[2] li[2]').innerHTML
or
$('#18 .data[2] li')[2].innerHTML
or
$('.data[2] li[2]',$('#18')).innerHTML
or
$('.data[2] li',$('#18'))[2].innerHTML[/quote]
see your codes now are smaller and more efficient to use,
you can combine any [b]Id[/b] or [b]ClassName[/b] or [b]TagName[/b] in just one string
to map the one that you need.
Hope it helps,
~im open for any suggestions
[color=#999999]____________________________________________________________[/color]
[color=#555555]older post[/color]
[spoiler][quote][b]CROSSBROWSER[/b] sure for IE and Firefox only.
tnx to sir [url=http://theftalk.com/profile.php?id=3509]feruzz[/url]

[/quote]
I release this too early because im very excited

After playing with the codes,
I've invented a bunch of functions that will easily get the content in your page according to its command

This will make you design and modify your page easily because all you need to do is call the function that carries the content like URL, innerHTMl etc..
confusing?
Here it is:
[color=green]The function:[/color] [color=red][b]getCommentName([i]index_num[/i])[/b][/color]
[color=green]Parameter:[/color] [b]index_num[/b]
Any number from 1 - 10, represent the 10 commentators in your public comments
[color=green]Usage:[/color]
get the name of the commentator according to its index
__________________________________________________
[color=green]The function:[/color] [color=red][b]getCommentLink([i]index_num[/i])[/b][/color]
[color=green]Parameter:[/color] [b]index_num[/b]
Any number from 1 - 10, represent the 10 URL of commentators in your public comments
[color=green]Usage:[/color]
get the URL of the commentator according to its index
__________________________________________________
[color=green]The function:[/color] [color=red][b]getCommentDate([i]index_num[/i])[/b][/color]
[color=green]Parameter:[/color] [b]index_num[/b]
Any number from 1 - 10, represent the 10 dates posted in your public comments
[color=green]Usage:[/color]
get the date posted according to its index
__________________________________________________
[color=green]The function:[/color] [color=red][b]getCommentData([i]index_num[/i])[/b][/color]
[color=green]Parameter:[/color] [b]index_num[/b]
Any number from 1 - 10, represent the content in your public comments
[color=green]Usage:[/color]
get the content of a comment according to its index
__________________________________________________
[color=green]The function:[/color] [color=red][b]getCommentPic([i]index_num[/i])[/b][/color]
[color=green]Parameter:[/color] [b]index_num[/b]
Any number from 1 - 10, represent the URL of the pictures of commentators in your public comments
[color=green]Usage:[/color]
get the URL of the picture according to its index
__________________________________________________
[color=green]Examples:[/color]
Here is my comments:
[img]http://i173.photobucket.com/albums/w76/myparis16/p1-2.jpg[/img]
Observe the functions:
[b]getCommentName([i]2[/i])[/b] = Returns "Myparis"
[b]getCommentName([i]6[/i])[/b] = Returns "Marks"
[b]getCommentLink([i]2[/i])[/b] = Returns "http://profiles.friendster.com/20140652"
[b]getCommentLink([i]6[/i])[/b] = Returns "http://profiles.friendster.com/64678447"
[b]getCommentDate([i]2[/i])[/b] = Returns "Posted 03/19/2008 1:14 pm"
[b]getCommentDate([i]6[/i])[/b] = Returns "Posted 03/19/2008 9:13 am"
[b]getCommentData([i]2[/i])[/b] = Returns "testing"
[b]getCommentData([i]6[/i])[/b] = Returns "Comment 2"
[b]getCommentPic([i]2[/i])[/b] = Returns "http://photos-652.friendster.com/e1/photos/25/60/20140652/1_557103409m.jpg"
[b]getCommentPic([i]6[/i])[/b] = Returns "http://photos.friendster.com/photos/74/48/64678447/1_276582702m.jpg"
__________________________________________________
For now i just have 5 functions available, more to come soon..

To use it download this [url=http://mark16.fileave.com/Friendster/testpage/myparisFSContentLibV1.js]myparisFSContentLibV1[/url]
then merge it in your js file like this:
[quote]var fscontentlib = document.createElement("script");
fscontentlib.src = "[b]URL_OF_myparisFSContentLibV1_file[/b]";
document.getElementsByTagName("head")[0].appendChild(fscontentlib);[/quote]
Then in your onload handler, Initialized the main function first before your use the other functions i made,
so it will succesfully get the contents:
This is the main function [b]MYPARIS_INIT_FS_CONTENT_LIB()[/b], put it in the very first of all other functions
[quote]if(!attachOnLoadHandler(function(){onProfileLoad()}))window.onload=function(){onProfileLoad()};
function onProfileLoad(){
[b]MYPARIS_INIT_FS_CONTENT_LIB()[/b];
[i]other_functions();[/i]
[i]other_functions();[/i]
[i]other_functions();[/i]
[i]other_functions();[/i]
}[/quote]
Then thats it you can now use the 5 functions i made, and you can now design whatever you want in your comments area or in others... Its up to you how will you design it like what i did
Img Previews:
[img]http://i173.photobucket.com/albums/w76/myparis16/p2-2.jpg[/img]
[img]http://i173.photobucket.com/albums/w76/myparis16/preview3.jpg[/img]
Live Preview:
http://profiles.friendster.com/markstestpage
[b]Combine this tutorial with
http://theftalk.com/t24164-Flash-Tuts-Using-FlashVars.html
so you can make a trick like this
http://profiles.friendster.com/myparis
[/b]
More functions to come, ill just update my post.
again here his the available functions for now
[quote]getCommentName(index_num);
getCommentLink(index_num);
getCommentDate(index_num);
getCommentData(index_num);
getCommentPic(index_num);[/quote]
[/spoiler]
Last edited by myparis (2008-08-31 10:29:11)