Simie
Coding Admin
Why are you all still here?
Posts: 721
|
Post by Simie on Jan 13, 2007 7:02:44 GMT -5
Breakdown of the forum resize code... <script type="text/javascript"> <!-- fWidth = document.getElementsByTagName('table'); for(t=0; t<fWidth.length; t++) { if(fWidth[t].width=="92%") fWidth[t].width='750'; } // --> </script> <script type="text/javascript"> <!-- If I have to explain this bit to you, then I'll kill you >_> fWidth = document.getElementsByTagName('table'); This is simple grabbing all the tables on the page, and assigning a variable to them. for(t=0; t<fWidth.length; t++) { This is looping through all the tables on the page... if(fWidth[t].width=="92%") This checks whether the current table being looped through has a width of 92%. (92% is the default width of the page) fWidth[t].width='750'; This resizes the table. Simple as that } // --> </script> This just finishes the loop, and ends the script. Done =O
|
|
~CrAzY~™
Community Admin
The Karate Kid
What?.. Nosy Jerk..
Posts: 3,129
|
Post by ~CrAzY~™ on Jan 13, 2007 14:56:53 GMT -5
Thanks a ton! That really helps a lot. So, let me get this straight... fWidth = document.getElementsByTagName('table'); - This takes the word table and gives it the id of fWidth? Or is it the other way around? for(t=0; t<fWidth.length; t++) { - Erm... Can you break down this little piece? I know what it general will do, but how does it work? if(fWidth[t].width=="92%") - That means... "If the forum width is 92%, then..." right? fWidth[t].width='750'; - This uses the above if statement to set the forum to 750px? If I'm wrong in my interpretation, please tell me.
|
|
|
Post by Dustin ™ on Jan 13, 2007 15:00:56 GMT -5
Thanks a ton! That really helps a lot. So, let me get this straight... fWidth = document.getElementsByTagName('table'); - This takes the word table and gives it the id of fWidth? Or is it the other way around? for(t=0; t<fWidth.length; t++) { - Erm... Can you break down this little piece? I know what it general will do, but how does it work? if(fWidth[t].width=="92%") - That means... "If the forum width is 92%, then..." right? fWidth[t].width='750'; - This uses the above if statement to set the forum to 750px? If I'm wrong in my interpretation, please tell me. I think with the percentage and pixel size it would be this: Say you wanted your forums width to be 700. You would multipy 700 by .92 and then thats what you would put in the next line. So it would look like: if(fWidth[t].width=="92%") fWidth[t].width='644';
(hopefully i got that right. ;D)
|
|
~CrAzY~™
Community Admin
The Karate Kid
What?.. Nosy Jerk..
Posts: 3,129
|
Post by ~CrAzY~™ on Jan 13, 2007 15:12:08 GMT -5
Actually, I'm pretty sure it's an if/then statement. (pop-up 101 ) if(fWidth[t].width=="92%") fWidth[t].width='644';
Translation: "If the forum width is 92% (of the screen size), then the forum width equals (changes to) 644 pixels wide."
|
|
|
Post by Dustin ™ on Jan 13, 2007 15:13:55 GMT -5
Actually, I'm pretty sure it's an if/then statement. (pop-up 101 ) if(fWidth[t].width=="92%") fWidth[t].width='644';
Translation: "If the forum width is 92% (of the screen size), then the forum width equals (changes to) 644 pixels wide." So basically you just said what I said in an If / Then statement right? Because it would still 700px right? Im pretty sure thats what I did in the template I made. ;D
|
|
Simie
Coding Admin
Why are you all still here?
Posts: 721
|
Post by Simie on Jan 13, 2007 15:36:08 GMT -5
Nono, if you wanted 700 pixels, you would use 700 not 644...
|
|
~CrAzY~™
Community Admin
The Karate Kid
What?.. Nosy Jerk..
Posts: 3,129
|
Post by ~CrAzY~™ on Jan 13, 2007 15:36:42 GMT -5
No, I said what it does. When you put 644, that becomes the new forum width and not 700px.
If it's this thing, then do this. That's the basic of an if/then statement.
If the forum width is 92% Then change to 700px That's the statement this is using.
See what I'm saying?
|
|
Simie
Coding Admin
Why are you all still here?
Posts: 721
|
Post by Simie on Jan 13, 2007 15:43:32 GMT -5
Its not the forum width, its the tables width =P Basicly... If it finds a table with a width of 92%: Resize it to 700px
|
|
~CrAzY~™
Community Admin
The Karate Kid
What?.. Nosy Jerk..
Posts: 3,129
|
Post by ~CrAzY~™ on Jan 13, 2007 15:48:31 GMT -5
That's what I was basically referring to... for(t=0; t<fWidth.length; t++) { but could you please break that down? I don't understand it good... (Maybe break it down in the top post)
|
|
Simie
Coding Admin
Why are you all still here?
Posts: 721
|
Post by Simie on Jan 13, 2007 15:53:24 GMT -5
for( Starting the loop statement... t=0; This is basically just saying that t = 0, this is only said once, and is not repetedly done... t<fWidth.length; This says that if t is less than the amount of tables on the page... t++) { Add 1 to t
|
|
~CrAzY~™
Community Admin
The Karate Kid
What?.. Nosy Jerk..
Posts: 3,129
|
Post by ~CrAzY~™ on Jan 13, 2007 16:10:34 GMT -5
What what is t?
|
|
Simie
Coding Admin
Why are you all still here?
Posts: 721
|
Post by Simie on Jan 13, 2007 16:25:45 GMT -5
Nothing. You can use any letter there. Its just the variable that holds the current number or whatever...
|
|
~CrAzY~™
Community Admin
The Karate Kid
What?.. Nosy Jerk..
Posts: 3,129
|
Post by ~CrAzY~™ on Jan 13, 2007 17:04:12 GMT -5
oooh, ok lol.
|
|
Samuel
Former Coding Moderator
:D
Posts: 154
|
Post by Samuel on Feb 3, 2007 4:55:16 GMT -5
Try looking at a loops tutorial! Helped me ten tonnes!
|
|