Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8926949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:06:34+00:00 2026-06-15T08:06:34+00:00

Please help! I have been cracking this for days but no avail.. :( I

  • 0

Please help! I have been cracking this for days but no avail.. 🙁 I can’t hide/ show Previous / Next buttons as of my following scenarios..

I have a 3 images array. Each individual image is shown using Previous / Next buttons. The scenario are as follows:

  • P1 Image is shown: Hide Previous Button, show Next Button

  • P2 Image is shown: Show Previous & Next Button

  • P3 image is shown: Hide Next Button, Show Previous Button

My codes are as follows:

Javascript:

var myPix = new Array()

myPix[0] = 'P1.jpg'
myPix[1] = 'P2.jpg'
myPix[2] = 'P3.jpg'

var thisPic = 0

function doPrevious() {
    if (document.images && thisPic > 0) {
        thisPic--
        document.myPicture.src=myPix[thisPic]
    }
}

function doNext() {
    if (document.images && thisPic < 2) {
        thisPic++
        document.myPicture.src=myPix[thisPic]
    }
}

HTML codes:

Previous / Next Buttons here:

<td height="47" align="right">
    <a href="javascript:doPrevious()" title="Previous">
        <img src="PrevBtn.jpg" width="120" height="35" border="0" />
    </a>
    <a href="javascript:doNext()" title="Next">
        <img src="NextBtn.jpg" width="120" height="35" border="0" />
    </a>
</td>

Image shown here:

<table border="0" align="center" cellpadding="0" cellspacing="0" id="Table_01">
    <tr>
        <td>
            <img id="pic" name="myPicture" src="P1.jpg" />
        </td>
    </tr>
</table>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T08:06:35+00:00Added an answer on June 15, 2026 at 8:06 am

    Try changing the constants in your if statements to 1 because you want the ‘next’ picture to be hidden only when thisPic = 2 and ‘prev’ hidden when thisPic = 0.

    Look at the lines with *.style.display and see if you get what they’re doing. It would probably be beneficial to look up html attributes and properties. http://www.w3schools.com/jsref/prop_style_display.asp

    function doPrevious() {
        var pic = document.getElementById("pic");
        var next = document.getElementById("next");
        if (document.images && thisPic > 1) {
            thisPic--;
            pic.src=myPix[thisPic];
            next.style.display = "none";
        }
        else document.getElementById("next").style.display = "block";
    }
    
    function doNext() {
        var pic = document.getElementById("pic");
        var prev = document.getElementById("prev");
        if (document.images && thisPic < 1) {
            thisPic++;
            pic.src=myPix[thisPic];
            prev.style.display = "none";
        }
        else prev.style.display = "block";
    }
    

    Edit your html to give prevBtn and NextBtn ids like so:

    <td height="47" align="right"><a href="javascript:doPrevious()" title="Previous"><img src="PrevBtn.jpg" id = "prev" width="120" height="35" border="0" /></a>
    

    Then you can call document.getElementById(id) when you need it and change their style property to “none” as above.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please help! I have been grappling with this error for days and I cannot
Can someone please help. I have been searching and encountered/modified this code I am
Can anyone please help me out.I have been stuck with this NSMutableArray for last
please help, i have been working on this for 2 days now, i cant
Please help me, or show me direction. I have been searching net for this
may be too simple groovy question but....please help i have a list like this:
I have been stuck on this all weekend and failed miserably! Please help me
I have been trying to figure the following for a couple days. Please HELP
first time poster, but please help. I have been searching and reconfiguring for 6
Please help if you can. I have been trying to access the current session

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.