> > "news.dev.ict.nl" <to**@xs4all.nl> wrote
Hi,
I want to show the value of a counter-variable that is incremented
with a button. How do I refresh the page after the button is pressed ?
Looks pretty basic but I cannot find the answer in the books.....
Below is a simple example that shows what I want
Ton den Hartog
<html>
<head>
<script type='text/javascript'>
function inc()
{
count=count+1;
// how to refresh now ??
}
</script>
</head>
<body>
<script type='text/javascript'>
var count
count=0;
</script>
<script type='text/javascript'>
document.write("Count is now "+count);
</script>
<input type=button id=date_edit value='...' OnClick='inc();'>
</body>
</html>
"Gill Bates" <g.*****@mothail.com> wrote If you only want the number client-side the best would be to stuff
the value in something with an id, so you can easily reference it with a
JavaScript DOM call and change it's value.
"Ton den Hartog" <to**@xs4all.nl> wrote But after the value is changed the text does not automatically change,
how do I accomplisch that ?
Ton
Hi Ton, try this example...
<html>
<head>
<script type="text/javascript">
var count = 0;
function inc()
{
count = count + 1;
document.getElementById('x').firstChild.nodeValue = count;
}
</script>
</head>
<body>
<p>Count is now <span id="x">0</span></p>
<form>
<input type="button" id="date_edit" value="..." onclick="inc()">
</form>
</body>
</html>
Hope this helps
Geoff