Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    Dec 2003
    Posts
    85
    Thanks
    0
    Thanked 0 Times in 0 Posts

    updateing document.write

    ok, i'm using document.write to show the value of a variable.
    Code:
    document.write("Variable 1 equals " + (variable 1) + " .");
    if the value of variable 1 changes, how do I get it to say the new value?

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Location
    Kansas City, Kansas
    Posts
    1,518
    Thanks
    0
    Thanked 2 Times in 2 Posts
    After it has already been written to the page you would have to use innerHTML.

  • #3
    New to the CF scene
    Join Date
    Mar 2004
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    <script>
    function add(){
    a.innerHTML=eval(a.innerHTML)+1;
    }
    </script>
    <button onclick=add()>click me</button>
    <div id="a">1</div>

  • #4
    New Coder
    Join Date
    Dec 2003
    Posts
    85
    Thanks
    0
    Thanked 0 Times in 0 Posts
    is there something i can use instead of document.write that would automattically change it as soon as it changes? i dont want to have to resort to alert messages. Would a text field change instantly?

  • #5
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Originally posted by the_bob
    is there something i can use instead of document.write that would automattically change it as soon as it changes? i dont want to have to resort to alert messages. Would a text field change instantly?
    Yes, just as Antonio said. innerHTML!

    Code?

    .....Willy

  • #6
    New Coder
    Join Date
    Dec 2003
    Posts
    85
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Originally posted by peasantry
    <script>
    function add(){
    a.innerHTML=eval(a.innerHTML)+1;
    }
    </script>
    <button onclick=add()>click me</button>
    <div id="a">1</div>
    wouldn't that make it so you would have to click a button???

  • #7
    New Coder
    Join Date
    Dec 2003
    Posts
    85
    Thanks
    0
    Thanked 0 Times in 0 Posts
    oh, just realised that Inner HTML was a link
    i'll go check that out now


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •