Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
moving forward and backwards with div images using submit button
Old 08-03-2010, 04:05 PM moving forward and backwards with div images using submit button
Webmaster Talker

Posts: 611
Trades: 0
Hi, I don't know how to code this, I was wondering if someone could give me an idea. I want to have a html submit button change the image on a div every time the button "forward" is pressed, then I want a "backwards" button to change the pictures in reverse order.

The only thing I can think of is this.

if !empty post forward

change div img

if !empty post forward

change div image.

repeated and I'm positive that's not going to work. LOL.

I do know how to change the div image with the submit button already, but not in the way that I am describing above. Thanks. Derek
silverglade is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-03-2010, 05:20 PM Re: moving forward and backwards with div images using submit button
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,384
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
just step through an array.

forward button sends [current]+1
back button sends [current]-1

if 0 use the array.length.
if array.length use 0
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 08-03-2010, 05:27 PM Re: moving forward and backwards with div images using submit button
Webmaster Talker

Posts: 611
Trades: 0
man Chris you are da MAN! you've helped me so many times. thanks again. I really appreciate all of your help. Thanks. Derek

Last edited by silverglade; 08-03-2010 at 05:29 PM..
silverglade is offline
Reply With Quote
View Public Profile
 
Old 08-04-2010, 08:00 AM Re: moving forward and backwards with div images using submit button
Experienced Talker

Posts: 48
Name: Websys_seo
Location: India
Trades: 0
Quote:
Originally Posted by chrishirst View Post
just step through an array.

forward button sends [current]+1
back button sends [current]-1

if 0 use the array.length.
if array.length use 0
that's a good idea,
store each image name with location in arrayi.e
PHP Code:
$image[0]="location/image1.jpg";
$image[1]="location/image2.jpg" 
.... like wise

Now as the page loads use
PHP Code:
$image_key=0
with every forward button use
PHP Code:
$image_key=$image_key++; 
Now in display section use
PHP Code:
<image src="<?php echo $image['$image_key'];?>">

Last edited by chrishirst; 08-04-2010 at 08:04 AM.. Reason: delimiters added
Arings is offline
Reply With Quote
View Public Profile Visit Arings's homepage!
 
Old 08-04-2010, 09:00 AM Re: moving forward and backwards with div images using submit button
Webmaster Talker

Posts: 611
Trades: 0
I'm trying to use the "next()" function to change my array images in the div. But I get a black screen inside the div, no image. Here is the array I'm using .

Code:
$teardrop_ocean_bg = array
    (
    'level_1'=>"<img src='<img src='sundragon_environments/ocean/ocean1_FRAME.jpg'/>'",
    'level_2'=>"<img src='<img src='sundragon_environments/ocean/ocean1_FRAME2.jpg'/>'",
    'level_3'=>"<img src='<img src='sundragon_environments/ocean/ocean1_FRAME3.jpg'/>'",
    'level_4'=>"<img src='<img src='sundragon_environments/ocean/ocean1_FRAME4.jpg'/>'",
    'level_5'=>"<img src='<img src='sundragon_environments/ocean/ocean1_FRAME5.jpg'/>'"
    );
and here is the code to go through the array when the "further" button is pressed.

Code:
$currentLocation='teardrop_ocean';//declare variables/this is set after we click on image map link for teardrop
$currentLocArray='';
//the following is set after we click on the teardrop ocean link on the image map .

//check if the current location is teardrop ocean, if so, set current loc array to the teardrop ocean bg array.
if($currentLocation=='teardrop_ocean'&& !empty($_POST['further']))
{
     $echoLocation=next($teardrop_ocean_bg);
}
I echo out the $echoLocation later on in the div.
silverglade is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to moving forward and backwards with div images using submit button
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.14985 seconds with 12 queries