Welcome Guest [Log In] [Register]
Search Members Calendar | Rules ZB Code Index IF Code Index
ZBCode
  • Navigation
  • ZBCode
  • Coding Support
  • Code University
  • Groups in ZB
Hey, welcome to ZBCode, the premier coding forum for ZB. Here you fill find some of the best Invisionfree and Zetaboards Codes on the network! Unfortunately, you're sorta hovering around in guest mode at the moment; why not join in on the fun? Register an account and you can start accessing the wealth of resources we have available here. Enjoy your stay at ZBCode, and remember to tell all your friends about us; the more members, the more codes available. ;)

Interested in joining? Click here.


If you are already a member of ZBCode, feel free to login right here:

Username:   Password:
Locked Topic
  • Pages:
  • 1
  • 2
  • 3
Groups in ZB
Tweet Topic Started: Jun 10 2009, 06:33 PM (594 Views)
Dorith Jun 10 2009, 06:33 PM Post #1
Member Avatar
Has just entered the Matrix

Posts:
2,069
Group:
Former Staff
Member
#1,854
Joined:
Dec 23, 2008
So I'm sorta trying to get the hand of Javascript and am trying to learn some new things. I was wondering how to set up an if statement per group? I noticed that if you look at the source of the member list in the forums you will see a value for each forum group.

How would you set up the if statement part of that code? Because right after that I would use something like
Code:
 
document.write("New Video Team Board up...etc.");

Correct? And that would work with showing that announcement only to the specific group?
Posted Image
Posted Image
(Made emoticon using Codes Rock's Smiley Generator)
Offline Profile Goto Top
 
Reid Jun 10 2009, 06:42 PM Post #2
Member Avatar
What? The land of the free? Whoever told you that was your enemy.

Posts:
1,790
Group:
Distinguished Coder
Member
#148
Joined:
Jul 20, 2008
Okay, so, where are you trying to write this message exactly?
The Resource Board
Offline Profile Goto Top
 
Dorith Jun 10 2009, 06:43 PM Post #3
Member Avatar
Has just entered the Matrix

Posts:
2,069
Group:
Former Staff
Member
#1,854
Joined:
Dec 23, 2008
Where?? Err... I guess I'd have to do it on the forums for it to work...
Posted Image
Posted Image
(Made emoticon using Codes Rock's Smiley Generator)
Offline Profile Goto Top
 
Reid Jun 10 2009, 06:45 PM Post #4
Member Avatar
What? The land of the free? Whoever told you that was your enemy.

Posts:
1,790
Group:
Distinguished Coder
Member
#148
Joined:
Jul 20, 2008
I mean. You have to put your script somewhere. Is it going to write at the top of every page? Only when you're on the members page? On a post somewhere?
The Resource Board
Offline Profile Goto Top
 
Dorith Jun 10 2009, 06:48 PM Post #5
Member Avatar
Has just entered the Matrix

Posts:
2,069
Group:
Former Staff
Member
#1,854
Joined:
Dec 23, 2008
Oh, I see what you're saying. No it's gonna be on every page, just like an announcement box up top. So the location will be everywhere. So I don't need a "location.href" right? Or do I actually gotta put that?
Posted Image
Posted Image
(Made emoticon using Codes Rock's Smiley Generator)
Offline Profile Goto Top
 
Reid Jun 10 2009, 06:50 PM Post #6
Member Avatar
What? The land of the free? Whoever told you that was your enemy.

Posts:
1,790
Group:
Distinguished Coder
Member
#148
Joined:
Jul 20, 2008
If it's going to be on every page, then no. But there is a problem. How are you going to tell what group they are in on every page? It only says it in the member list (if they are on the page that includes their name), their profile, and when they post. And maybe a few other times.

On the index, for instance. The only way you're going to be able to tell is the color - and that's if you have the legend on. But that requires some fancy javascript. :P
The Resource Board
Offline Profile Goto Top
 
Dorith Jun 10 2009, 06:56 PM Post #7
Member Avatar
Has just entered the Matrix

Posts:
2,069
Group:
Former Staff
Member
#1,854
Joined:
Dec 23, 2008
But they are in a group. I see where you're getting at. So there's no place where the person is identified in a group? Because the person can see forums specific to their group/forum access. Perhaps it could be set up per forum access? The only problem with that is that I don't think that shows anywhere.

It's most likely php right?
Posted Image
Posted Image
(Made emoticon using Codes Rock's Smiley Generator)
Offline Profile Goto Top
 
Reid Jun 10 2009, 06:59 PM Post #8
Member Avatar
What? The land of the free? Whoever told you that was your enemy.

Posts:
1,790
Group:
Distinguished Coder
Member
#148
Joined:
Jul 20, 2008
Yeah it could be set up forumwise. If such and such forum exists, do this. Do you want jQuery or the classic JS way?
The Resource Board
Offline Profile Goto Top
 
Dorith Jun 10 2009, 07:08 PM Post #9
Member Avatar
Has just entered the Matrix

Posts:
2,069
Group:
Former Staff
Member
#1,854
Joined:
Dec 23, 2008
Oh! I get ya now. So it would be something like "if person can see this forum, then show this message" right?

Err, would there be no other way? Cause the person has to be in a group, and something in the forum has to tell it that that person is in said group.

Otherwise, please post the if part of the statement. I'm guessing it would something about what I quoted above about "if person can see location.href then document.write("blah"); correct?
Posted Image
Posted Image
(Made emoticon using Codes Rock's Smiley Generator)
Offline Profile Goto Top
 
Reid Jun 10 2009, 07:34 PM Post #10
Member Avatar
What? The land of the free? Whoever told you that was your enemy.

Posts:
1,790
Group:
Distinguished Coder
Member
#148
Joined:
Jul 20, 2008
Not quite. :P

If you want it the classic way,
Code:
 
//get all of the tr's on the page - (table rows)
var c = document.getElementsByTagName('tr');
//get how many there are so we can loop through them
var b = c.length;
//start our while loop
while (b--) {
// if this <tr> has an id that contains 'forum' (to make our code more efficient
if (c[b].id.indexOf("forum")!=-1) {
// indexOf returns -1 if the thing you're checking for doesn't exist
// so we say "if the indexOf such and such thing is NOT -1, go ahead
// get all of the links inside of this <tr>
var d = c[b].getElementsByTagName('a');
var e = d.length;
while (e--) {
// if this link, or any of the links, in this <tr> contain 'FORUM NAME HERE', go ahead
if (d[e].innerHTML.indexOf("FORUM NAME HERE")!=-1) {
// go ahead and write 'blah'
document.write('blah');
// and since we found the link we wanted, might as well stop the code here
break;
}
}
}
}
I went ahead and indented it so you can read it a little easier. I highly suggest downloading Notepad++, setting the 'Language' to javascript, and pasting this code in there, so the comments appear green and not the same color.
The Resource Board
Offline Profile Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
Go to Next Page
« Previous Topic · Code University · Next Topic »
Locked Topic
  • Pages:
  • 1
  • 2
  • 3

Track Topic · E-mail Topic Time: 7:47 PM Jul 10
Hosted for free by ZetaBoards · Privacy Policy