...

View Full Version : Variable not getting established



Var_javaMasta
04-20-2005, 11:39 PM
I have no clue about javascript, so there might be a simple problem that i just don't know about.

this is in my HTML file:

<SCRIPT type="Javascript">
<!--

picNum=1
picNumString="01"

//-->
</SCRIPT>

I dont know whats wrong, cuz when i try to run an alert telling me the value of picNum, there is an error.

<button type="button" onClick="alert(picNum)">Current pic</button>

Doesn't work... no alert even shows up.

BaldEagle
04-21-2005, 03:04 AM
Try
<input type="button" onClick="alert(picNum)" value="Current pic">

BaldEagle

glenngv
04-21-2005, 03:12 AM
You had the wrong script type. This is the correct type.

<script type="text/javascript">

rlemon
04-21-2005, 04:27 AM
<SCRIPT type="Javascript">
<!--

var picNum=1;
var picNumString="01";

//-->
</SCRIPT>


:cool:

glenngv
04-21-2005, 05:34 AM
<SCRIPT type="Javascript">
<!--

var picNum=1;
var picNumString="01";

//-->
</SCRIPT>


:cool:
That's optional but a good coding habit to put them. Just correcting the script type will solve the problem.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum