Java Script Help

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

Java Script Help
  1. Unread #1 - Sep 24, 2011 at 12:31 PM
  2. OneEyd
    Joined:
    Feb 20, 2010
    Posts:
    227
    Referrals:
    0
    Sythe Gold:
    0

    OneEyd Active Member
    $5 USD Donor

    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.
     
  3. Unread #2 - Sep 24, 2011 at 12:34 PM
  4. blindkilla
    Joined:
    Jun 22, 2005
    Posts:
    1,896
    Referrals:
    0
    Sythe Gold:
    6
    Discord Unique ID:
    282000633404456960
    Discord Username:
    sogord

    blindkilla Guru
    $25 USD Donor New

    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;">
    
     
  5. Unread #3 - Sep 24, 2011 at 12:41 PM
  6. OneEyd
    Joined:
    Feb 20, 2010
    Posts:
    227
    Referrals:
    0
    Sythe Gold:
    0

    OneEyd Active Member
    $5 USD Donor

    Java Script Help

    Worked perfectly, thank you.
     
  7. Unread #4 - Sep 24, 2011 at 12:44 PM
  8. blindkilla
    Joined:
    Jun 22, 2005
    Posts:
    1,896
    Referrals:
    0
    Sythe Gold:
    6
    Discord Unique ID:
    282000633404456960
    Discord Username:
    sogord

    blindkilla Guru
    $25 USD Donor New

    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? >

Users viewing this thread
1 guest


 
 
Adblock breaks this site