How to update the page ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • news.dev.ict.nl

    How to update the page ?

    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>


  • Geoff Tucker

    #2
    Re: How to update the page ?

    > > "news.dev.ict.n l" <tonh@xs4all.nl > wrote[color=blue][color=green][color=darkred]
    > > > Hi,
    > > >
    > > > I want to show the value of a counter-variable that is incremented[/color][/color][/color]
    with[color=blue]
    > a[color=green][color=darkred]
    > > > button. How do I refresh the page after the button is pressed ?[/color][/color][/color]
    Looks[color=blue][color=green]
    > > pretty[color=darkred]
    > > > 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>
    > > >
    > > >[/color][/color]
    > "Gill Bates" <g.bates@mothai l.com> wrote[color=green]
    > > If you only want the number client-side the best would be to stuff[/color][/color]
    the[color=blue]
    > value[color=green]
    > > in something with an id, so you can easily reference it with a[/color][/color]
    JavaScript[color=blue][color=green]
    > > DOM call and change it's value.
    > >
    > >[/color][/color]
    "Ton den Hartog" <tonh@xs4all.nl > wrote[color=blue]
    > But after the value is changed the text does not automatically change,[/color]
    how[color=blue]
    > do I accomplisch that ?
    >
    > Ton
    >[/color]
    Hi Ton, try this example...

    <html>
    <head>
    <script type="text/javascript">

    var count = 0;

    function inc()
    {
    count = count + 1;
    document.getEle mentById('x').f irstChild.nodeV alue = 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




    Comment

    • Ton den Hartog

      #3
      Re: How to update the page ?

      > count = count + 1;[color=blue]
      > document.getEle mentById('x').f irstChild.nodeV alue = count;
      > <input type="button" id="date_edit" value="..." onclick="inc()" >[/color]

      Hi, thanks but my real problem is more complex... :-) I have a big table
      with javascript with document.write' s in them that print text dependent upon
      a integer value that changes.
      I already thought about putting the value in a cooky and than reloading the
      whole page but I thought it could be done differently....

      Ton




      Comment

      Working...