L
lost hope
hi, i have a very simple html page with a global variable, a function
to increment its value, and a form that calls the function. however,
what happens is that every time i click the image, the page is
reloaded, and the value is reset to 1. is this what i should be
expecting? are global variables not persistent across reloads? if
this is the case, how can i set it up so that clicking the button
doesn't reload the page automatically, but rather just calls the
function. this is so frusterating
<html>
<head>
<script language="javascript">
var a=1;
function incValue()
{
a = a+5;
}
</script>
</head>
<body>
<form>
<input type="image" src="one.gif" onclick="incValue()"/>
</form>
</body>
</html>
to increment its value, and a form that calls the function. however,
what happens is that every time i click the image, the page is
reloaded, and the value is reset to 1. is this what i should be
expecting? are global variables not persistent across reloads? if
this is the case, how can i set it up so that clicking the button
doesn't reload the page automatically, but rather just calls the
function. this is so frusterating
<html>
<head>
<script language="javascript">
var a=1;
function incValue()
{
a = a+5;
}
</script>
</head>
<body>
<form>
<input type="image" src="one.gif" onclick="incValue()"/>
</form>
</body>
</html>