Click to See Complete Forum and Search --> : This is gonna be really stupid.


Burrow
04-12-2003, 07:54 PM
Today, My friend Mike and I were arguing about this little diddy, and I just wanted to make sure I'm right.


Okay heres what happens,

Since variables carry over, I can't have two of the same named ones even though they are in seperate scripts right?


<body>

<script language="Javascript">
var today= get Date();
var date= get Date();
etc....

</script>

Today is ....

<script language="Javascript">
var today= "4";
var date= "6";
etc....

</script>

</body>


I am right about this am I not, that would cause an error right?
Thanks.

SearedIce
04-12-2003, 08:36 PM
variables, when not defined in a function, are global, meaning they can be acessed by any javascript on the page

thus, you would be right -- but not entirely

ie wouldn't throw an error...the variables would simply be reassigned 4 and 6 in the lower part and anything you have using those variables (an alert, a textbox value, etc.) beyond that part in the source would use the values 4 and 6

i hope this helps and i hope I'm right

~John

Burrow
04-12-2003, 11:37 PM
aww, :(

I wanted to go and laugh my head off at him.

Oh well, I'm sure your right.

Thanks.