SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Jun 2006
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    change button text

    Hi all, I am a total javascript newbie, so this may seem like an easy fix, but I am stumped.

    I am trying to change the text on a button that swaps an image.

    here is the script that changes the image (this works ok)


    var pkProp1 = "cottage_small.jpg";

    if(document.images){
    var pkPropSm = new Image();
    pkPropSm.src = "cottage_small.jpg";

    var pkPropLg = new Image();
    pkPropLg.src = "cottage_large.jpg";
    }

    function swapProp(){
    if(document.images){
    if(pkProp1 =="cottage_large.jpg") pkProp1 = "cottage_small.jpg";
    else
    pkProp1 = "cottage_large.jpg";
    document.getElementById("prop1").src = pkProp1;
    }

    }

    }



    and here is the button that calls that function:


    <input type="button" id="propBttn" value="view larger image" onclick="swapProp()" />

    I can't figure out how to make two things happen with one event...
    please help!

    feeling stupid,
    rooster

  2. #2
    Non-Member DelvarWorld's Avatar
    Join Date
    Jul 2004
    Location
    Baloney
    Posts
    341
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm a little confused because you don't actually try to change the button's value in your code. But I think this is what you want:
    Code:
    document.getElementById('propBttn').value = 'New Value';
    Put that inside your swapProp function


Bookmarks

Posting Permissions

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