Adblock breaks this site

innerHTML and getElementById()

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

  1. rubiksmaster12

    rubiksmaster12 Active Member
    $5 USD Donor

    Joined:
    Aug 9, 2007
    Posts:
    115
    Referrals:
    0
    Sythe Gold:
    0
    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?
     
  2. cp

    cp an cat
    Banned

    Joined:
    Jan 30, 2007
    Posts:
    3,278
    Referrals:
    6
    Sythe Gold:
    0
  3. rubiksmaster12

    rubiksmaster12 Active Member
    $5 USD Donor

    Joined:
    Aug 9, 2007
    Posts:
    115
    Referrals:
    0
    Sythe Gold:
    0
    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>
    
     
  4. rubiksmaster12

    rubiksmaster12 Active Member
    $5 USD Donor

    Joined:
    Aug 9, 2007
    Posts:
    115
    Referrals:
    0
    Sythe Gold:
    0
    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
     
  5. cp

    cp an cat
    Banned

    Joined:
    Jan 30, 2007
    Posts:
    3,278
    Referrals:
    6
    Sythe Gold:
    0
    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 >


 
 
Adblock breaks this site