innerHTML and getElementById()

Discussion in 'Web Programming' started by rubiksmaster12, Jan 26, 2008.

innerHTML and getElementById()
  1. Unread #1 - Jan 26, 2008 at 10:15 PM
  2. rubiksmaster12
    Joined:
    Aug 9, 2007
    Posts:
    115
    Referrals:
    0
    Sythe Gold:
    0

    rubiksmaster12 Active Member
    $5 USD Donor

    innerHTML and getElementById()

    I've been trying to learn how to use innerHTML and getElementById() in javascript scripts but I can never get it to work. Does anyone know a good site to learn how to use those?
     
  3. Unread #2 - Jan 26, 2008 at 10:54 PM
  4. cp
    Joined:
    Jan 30, 2007
    Posts:
    3,278
    Referrals:
    6
    Sythe Gold:
    0

    cp an cat
    Banned

  5. Unread #3 - Jan 27, 2008 at 12:02 AM
  6. rubiksmaster12
    Joined:
    Aug 9, 2007
    Posts:
    115
    Referrals:
    0
    Sythe Gold:
    0

    rubiksmaster12 Active Member
    $5 USD Donor

    innerHTML and getElementById()

    Ok, I'm trying to make a script that will count up as you click the button. I keep getting errors and I don't know what I'm doing wrong. Here's the code. I've tried a couple times and this was the latest attempt.

    Code:
    <script type="javascript">
    
    score = 0;
    
    function count() 
    {
    document.getElementById('click').innerHTML='Clicks: '+score+'';
    score++;
    }
    
    </script>
    <body>
    <div id="click">Clicks: 0</div>
    <form>
    <input type='button' value='click' onClick='count();'>
    </form>
    
    </body>
    
     
  7. Unread #4 - Jan 27, 2008 at 12:06 AM
  8. rubiksmaster12
    Joined:
    Aug 9, 2007
    Posts:
    115
    Referrals:
    0
    Sythe Gold:
    0

    rubiksmaster12 Active Member
    $5 USD Donor

    innerHTML and getElementById()

    Omg, I'm really stupid. I forgot to put "text/" in the script type. Didn't even realize it until I posted it. :p
     
  9. Unread #5 - Jan 27, 2008 at 12:37 AM
  10. cp
    Joined:
    Jan 30, 2007
    Posts:
    3,278
    Referrals:
    6
    Sythe Gold:
    0

    cp an cat
    Banned

    innerHTML and getElementById()

    Heheh, better watch out for simple things like that; overlooking something so small, especially in big pieces of code can really throw you off.
     
< Js help | CSS and myspace >

Users viewing this thread
1 guest


 
 
Adblock breaks this site