Adblock breaks this site

Java Script Help

Discussion in 'Programming General' started by OneEyd, Sep 24, 2011.

  1. OneEyd

    OneEyd Active Member
    $5 USD Donor

    Joined:
    Feb 20, 2010
    Posts:
    227
    Referrals:
    0
    Sythe Gold:
    0
    Java Script Help

    So I am just starting out doing Java and I am having a problem with contracting an image. We are supposed to make an image double in size on a button click and reduce in size when a different button is clicked. Can't seem to get the image to reduce.

    This is the code to get it to enlarge, this works fine.

    onclick="document.getElementById('Boba').height=2*
    document.getElementById('Boba').height;
    document.getElementById('Boba').width=2*
    document.getElementById('Boba').width;">


    I figured I could just replace the * with a /


    onclick="document.getElementById('Boba').height=2/
    document.getElementById('Boba').height;
    document.getElementById('Boba').width=2/
    document.getElementById('Boba').width;">

    This just makes the image disappear, any help on this would be appreciated, this is the only thing I can't figure out in this chapter.
     
  2. blindkilla

    blindkilla Guru
    $25 USD Donor New

    Joined:
    Jun 22, 2005
    Posts:
    1,896
    Referrals:
    0
    Sythe Gold:
    6
    Discord Unique ID:
    282000633404456960
    Discord Username:
    sogord
    Java Script Help

    If division doesn't work, try:

    Code:
    onclick="document.getElementById('Boba').height=
    document.getElementById('Boba').height*0.5;
    document.getElementById('Boba').width=
    document.getElementById('Boba').width*0.5;">
    
     
  3. OneEyd

    OneEyd Active Member
    $5 USD Donor

    Joined:
    Feb 20, 2010
    Posts:
    227
    Referrals:
    0
    Sythe Gold:
    0
    Java Script Help

    Worked perfectly, thank you.
     
  4. blindkilla

    blindkilla Guru
    $25 USD Donor New

    Joined:
    Jun 22, 2005
    Posts:
    1,896
    Referrals:
    0
    Sythe Gold:
    6
    Discord Unique ID:
    282000633404456960
    Discord Username:
    sogord
    Java Script Help

    No problem. If you need anymore help make a post or send me a PM for a quicker response.
     
< SendMessage in vb.net? | What's a good way to learn web design? >


 
 
Adblock breaks this site