Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Dec 2011
    Posts
    59
    Thanks
    51
    Thanked 1 Time in 1 Post

    ONCLICK ..... display new image in specific DIV

    from my spry sub.menu tab,
    i'm trying to use "onclick" to post a new img in a specific div elsewhere on the page.

    <li><a class="MenuBarItemSubmenu" href="#">CPQC</a>
    <ul>
    <li><a href="#" onclick="document.getElementById('cpqcRange').src='images/cpqc/cpqcHot.png';">Hot</a></li>
    </ul>
    </li>

    <div id="cpqcRange">
    <p>
    <img src="cpqcLocation.png" alt="cpqcLocation" name="cpqcLocation" width="504" height="360" id="cpqcLocation" />
    </p>
    </div>

    i think i'm close, but something is wrong.
    can you just call up the div "cpqcRange" by name and slap a new img.src in there???????

    cheers,
    Paul

    today's weather in Kalispell, MT, USA
    cold, brrrrr, not much snow, but it's coming soon
    it was about 18degF this morning
    Last edited by Paul Williams; 12-09-2011 at 02:52 AM.

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,462
    Thanks
    23
    Thanked 634 Times in 633 Posts
    Change the id to the img:

    Code:
    <a href="#" onclick="document.getElementById('cpqcRange').src='mages/cpqc/cpqcHot.png';">Hot</a>
    
    <div >
    <img id="cpqcRange" src="cpqcLocation.png" alt="cpqcLocation" name="cpqcLocation" width="140" height="240" id="cpqcLocation" />
    </div>

  • Users who have thanked sunfighter for this post:

    Paul Williams (12-09-2011)

  • #3
    New Coder
    Join Date
    Dec 2011
    Posts
    59
    Thanks
    51
    Thanked 1 Time in 1 Post
    thank you Sunfighter,

    it worked great !!!!



  •  

    Posting Permissions

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