Samuel
Former Coding Moderator
:D
Posts: 154
|
Huh?
Feb 16, 2008 12:53:05 GMT -5
Post by Samuel on Feb 16, 2008 12:53:05 GMT -5
Here are two scripts that are meant to do the same thing:
Code 1:
var iTable = document.getElementsByTagName('table'); for( b = 0; b < iTable.length; b++){ if(iTable[b].width == "92%"){ iTable.width = "700"; } }
Code 2:
var iTable = document.getElementsByTagName("table"); for(t=0; t<iTable.length; t++){ if(iTable[t].width == "92%"){ iTable[t].width="700"; } }
However, code one doesn't work and code two does. And if you look you'll see that there exactly the same, except from the letter used in the for() statement.
|
|
Simie
Coding Admin
Why are you all still here?
Posts: 721
|
Huh?
Feb 17, 2008 6:50:02 GMT -5
Post by Simie on Feb 17, 2008 6:50:02 GMT -5
var iTable = document.getElementsByTagName('table'); for( b = 0; b < iTable.length; b++){ if(iTable .width == "92%"){ iTable.width = "700"; } }
You forgot the on the first one
|
|
Samuel
Former Coding Moderator
:D
Posts: 154
|
Huh?
Feb 17, 2008 12:32:20 GMT -5
Post by Samuel on Feb 17, 2008 12:32:20 GMT -5
Ahhhh I spent like 20 minutes tryna find a problem and couldn't find it lol. Thanks simie *finds exalt*
|
|
Simie
Coding Admin
Why are you all still here?
Posts: 721
|
Huh?
Feb 17, 2008 15:33:44 GMT -5
Post by Simie on Feb 17, 2008 15:33:44 GMT -5
No problem
|
|
|
Huh?
Feb 29, 2008 22:11:40 GMT -5
Post by ZDesigns on Feb 29, 2008 22:11:40 GMT -5
Um and also.. var iTable = document.getElementsByTagName('table'); for( b = 0; b < iTable.length; b++){ if(iTable.width == "92%"){ iTable.width = "700"; } }
var iTable = document.getElementsByTagName("table"); for(t=0; t<iTable.length; t++){ if(iTable[t].width == "92%"){ iTable[t].width="700"; } }
1 has " and 1 has ' idk if that matters.. but if it does that is also a difference.
|
|
Samuel
Former Coding Moderator
:D
Posts: 154
|
Huh?
Mar 1, 2008 2:32:18 GMT -5
Post by Samuel on Mar 1, 2008 2:32:18 GMT -5
Quotes(') and Double Quotes(") in javascript do exactly the same thing, they're used for things like: document.write( "<a href= 'www.google.co.uk'>Google</a> "); Orange are single quotesRed are doubleIf we replace the single quotes for double ones, only part of the function will work: document.write( "<a href="www.google.co.uk">Google</a>"); Only the green bit will be read because you end it prematurely at the second double quote. The pink part will only give you (most probably) syntax errors.
|
|