MrAdam Posted March 25, 2006 Share Posted March 25, 2006 well i been having a lot of javascript problems since i started learning.. and they come about when i start using if statements. for example i made this. i have no clue whats wrong here but it wont work :S <script type="text/javascript">function test() {var test = alpha; If (test == "alpha") { document.write("YAY!"); }}</script> very simple.. yet it wont work :S Link to comment Share on other sites More sharing options...
Siddhesh Posted March 25, 2006 Share Posted March 25, 2006 well i been having a lot of javascript problems since i started learning.. and they come about when i start using if statements. for example i made this. i have no clue whats wrong here but it wont work :S<script type="text/javascript">function test() {var test = alpha; If (test == "alpha") { document.write("YAY!"); }}</script> very simple.. yet it wont work :S <{POST_SNAPBACK}> Just change the linevar test = alpha;By var test = "alpha";Because in the first case variable test is assign the value of variable alpha which is any random value.bye Link to comment Share on other sites More sharing options...
MrAdam Posted March 25, 2006 Author Share Posted March 25, 2006 still not getting my yay tho :S Link to comment Share on other sites More sharing options...
Siddhesh Posted March 25, 2006 Share Posted March 25, 2006 still not getting my yay tho :S<{POST_SNAPBACK}> r u using only this code or other event to call this function?Because ur function should gt invoked by some eventOkif u want to see the result do the following<script type="text/javascript"> var test = "alpha"; if(test=="alpha") { document.write("YAY!"); }</script> Note that "I" of if is small and not Big;Or Put a button in the html page and onclick event of that button call the function <script type="text/javascript">function test() { var test = "alpha"; if(test=="alpha") { document.write("YAY!"); }}</script> If u don't want to introduce html try the first code Link to comment Share on other sites More sharing options...
MrAdam Posted March 25, 2006 Author Share Posted March 25, 2006 ahh! I didnt realise the statement was case-sensitive - unlike PHP. Thanks. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now