Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 14th, 2005, 01:30 PM
Registered User
 
Join Date: Dec 2003
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Slide Show #1 (New User)

I have a simple photo slide show (rudimentary, but it works).

By pressing "next" & "previous" links on the page, the visitor can move from photo to photo.

I store the photos in an array (called myPix).

Above each slide, I would like the text: Slide 'n' of 'N' (where n = the number of the slide, i.e., its index number + 1; and N = the number of sides in the show, i.e., myPic.length).

Below each slide, I would like to display the name of the slide (for now, the file name of the photo in the array would be good enough).

Can anyone help me get started on this?

TYA.
Reply With Quote
  #2 (permalink)  
Old March 15th, 2005, 09:58 AM
Friend of Wrox
 
Join Date: Oct 2004
Location: delhi, delhi, India.
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919
Default

Hii WebDevel!!
Try this
Just replace the image array imgArray=new Array("img1.gif","img2.gif","img1.gif","img2.gif", "img1.gif","img2.gif")
to whatever you want

<body onload="setImage(1)">

 <input type=button id=first value=" &laquo;&laquo; " onclick="ShowImage(this)">
 <input type=button id=previous value=" &laquo; " onclick="ShowImage(this)">
 <input type=button id=next value=" &raquo; " onclick="ShowImage(this)">
 <input type=button id=last value=" &raquo;&raquo; " onclick="ShowImage(this)"><br>
  <span id="startindex"> </span>Out of <span id="endindex"> </span>Records
<br>

<image id="imageid" src="" border=0 >

</body>
<script>
imgArray=new Array("img1.gif","img2.gif","img1.gif","img2.gif", "img1.gif","img2.gif")
counter=1 //always shows first image from the array
function ShowImage(obj)
{
whichbtn=obj.id
local_index=1;
if(whichbtn=="first")
{
local_index=1;
counter=1;
}

else if(whichbtn=="next")
{
local_index=counter+1;
 counter++;
}
else if(whichbtn=="previous")
{

local_index=counter-1;
 counter--;
}
else if(whichbtn=="last")
{
local_index=imgArray.length;
 counter=imgArray.length;
}
setImage(local_index)

}

function setImage(indexval)
{
document.getElementById("imageid").src=imgArray[indexval-1];
setButtons(indexval,imgArray.length);
setText(indexval,imgArray.length);
}
function setText(x,y)
{
 document.getElementById("startindex").innerHTML=x
 document.getElementById("endindex").innerHTML=imgA rray.length
}
function setButtons(curr_counterx,totalimg)
{


if(curr_counterx==totalimg)
 {

  document.getElementById("last").disabled=true;
  document.getElementById("next").disabled=true;
  document.getElementById("previous").disabled=false ;
  document.getElementById("first").disabled=false;
 }

if(curr_counterx<totalimg && curr_counterx>1)
 {

  document.getElementById("last").disabled=false;
  document.getElementById("next").disabled=false;
  document.getElementById("first").disabled=false;
  document.getElementById("previous").disabled=false ;
 }


if(curr_counterx==1 && curr_counterx<totalimg)
 {

  document.getElementById("first").disabled=true;
  document.getElementById("previous").disabled=true;
  document.getElementById("last").disabled=false;
  document.getElementById("next").disabled=false;

 }



}
</script>
Hope this will help you


Cheers :)

vinod
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I show user name on our Intranet? sigilaea ASP.NET 2.0 Basics 2 July 12th, 2007 07:30 AM
xslt slide show kawlaelo XSLT 6 February 13th, 2007 10:41 AM
show data for a specific user momo BOOK: Professional ASP.NET 2.0 and Special Edition; ISBN: 978-0-7645-7610-2; ISBN: 978-0-470-04178-9 1 July 17th, 2006 09:08 PM
Image slide-show Rajarshi HTML Code Clinic 1 February 27th, 2006 06:03 AM



All times are GMT -4. The time now is 03:22 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.