...

View Full Version : Nested Javascript



worldtravlur
09-20-2010, 05:44 PM
Hello. I was wondering if there is a way to call a second Javascript function from within the first. For example:


<script>...call first function...</script>

Inside first function:


If (a==1)

<script>...call second function...</script>
else (a==2)

<script>...call third function...</script>


My thinking as to why I would need this is because I need to access two different Google Maps API codes.

If that isn't possible, does anyone have any other suggestions?

DrDOS
09-20-2010, 05:51 PM
If you have linked to the scripts on your page you don't need the inner script tags, just call the function, make sure that the links are before the functions are called and that you pass it the correct arguments.

If (a==1)

doThis(args):

else (a==2)

doThat(args);That's all you need to do.

worldtravlur
09-21-2010, 05:10 PM
Thank you DrDOS. That helps a lot!

Philip M
09-21-2010, 05:15 PM
If (a==1)


Javascript is case sensitive. If != if.

DrDOS - I think it would be a good idea if you only answered forum questions within your ability range.

DrDOS
09-21-2010, 10:15 PM
Javascript is case sensitive. If != if.

DrDOS - I think it would be a good idea if you only answered forum questions within your ability range.

I just copied and pasted his code, and missed the fact that he capped the if. sorry about that.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum