Please login or register. Welcome to the Studio, guest!


Quick Links:


newBookmarkLockedFalling

Scorpian

Scorpian Avatar

******
[ Bracket Admin ]

2,457


April 2006
This is a detailed explanation of my code for hiding the forum jump.

<script type='text/javascript'>
var riSelect = document.getElementsByTagName('select');
for(x = riSelect.length - 1; x >= 0; x--){
   if(riSelect[x].innerHTML.match(/Forum\sJump/i)){
      riSelect[x].style.display = 'none';
   }
}

</script>


Alright, let's get started. First off, we open the script with the standard opening tag for the HTML <script> feature.
<script type='text/javascript'>

Next, we declare a variable.
var riSelect = document.getElementsByTagName('select');

We have to tell the browser that this line declares a variable. Thus, we start with the var tag. Next, we name the varialbe. In this case, riSelect. We state that we're looking for a tag in the document. The purple part is the function getElementsByTagName(). Remember that JavaScript is case-sensitive. The blue part within the parenthases is the tag we're looking for. In this case, the <select> tag. Lastly, we end it with ; to state that this line is done.

Alright, now we'll loop through every <select> tag that is on this page. For the sake of loading speed, we'll start from the bottom up. Usually, the Forum Jump will be the first tag it finds when looping through them backwards.
for(x = riSelect.length - 1; x >= 0; x--){

We state that x will represent the number of the tag. The number is determined by the total amount of <select> tags - 1. This is because JavaScript starts counting from 0. We next state that x cannot be any less than 0. Finally, we say that after it reads a select tag, it will decrease the number x represents by 1.

Now we have a function that will find every select tag, and loop through them one by one. We're ready to check each one that it finds. We'll use an if statement to do so.
if(riSelect[x].innerHTML.match(/Forum\sJump/i)){

That stamement will find any <select> tag that has "Forum Jump" in it. This will be the forum jump 99.99% of the time.

Now that we have the forum jump tag available, we can do whatever we want to it. This next statement will tell the browser to hide the select box, thus making it invisible.
riSelect[x].style.display = 'none';

Now, the forum jump has been located, and hidden. We've done everything we were looking to do. Now, end the if statement. To do this, simply write a closing bracket ( } ). Afterwards, we'll have to end the for loop. Do this the same way. We now have no more needs for a script. Thus, close the tag.

That's it. I explained it so any idiot can understand it. This should be a big help to all of you coding n00bs looking to improve your coding :)


Last Edit: Aug 16, 2006 2:59:34 GMT by Scorpian
wat

Chris

Chris Avatar

******
Head Coder

19,519


June 2005
var riSelect = document.getElementsByTagName('select');[/color]


Broken color tag on that line. Also, this is more of a tutorial... care if I move it?

Scorpian

Scorpian Avatar

******
[ Bracket Admin ]

2,457


April 2006
Yeah. I started it out as an open source, but I guess I morphed into tutorial ;D Yeah, go ahead and move it.

*Also, I fixed the color thing :)
wat

newBookmarkLockedFalling