PDA

View Full Version : List/Menu changing my content



Tim Dobson
04-04-2010, 08:54 PM
I am very new to doing all this stuff so i need as much help as possible. I created a page that has a slideshow on it. The page is in php however that wont really concern this. To Display the slide show on the page i have put the slideshow script in its own page so the index is not filled up with all that jibberish... so my index uses the include to grab it out and display it.


<?php include ("includes/slideshow.php");?>

Ok so that is a success.

Now i have a drop-down menu


<select name="mydropdown">
<option value="List">View as list</option>
<option value="Show" selected="selected">View as slide-show</option>
</select>

And now im stuck!

What i need now is to change the content of the page if options are selected.

So lets say you are on my page and you change the drop-down menu to View as list.

I need it to be
<?php include ("includes/mylist.php");?>

instead of
<?php include ("includes/slideshow.php");?>

and if you selected View as slideshow in the drop-down it needs to be
<?php include ("includes/slideshow.php");?>

I have looked at many scripts etc to change content on a page and none of them make no sense to me so i wouldent be able to change to content to suite my needs.

Help is much appriciated. Thanks

jscheuer1
04-04-2010, 09:56 PM
Javascript (where I found this, and presumably where it was posted) isn't going to help you with a PHP include. Once the page is loaded, you cannot change the include. You could make the drop down list part of a form, submit it to the page itself (this would reload the page). Then you would end up with a

?mydropdown=Show

or a:

?mydropdown=List

appended to the URL. PHP could then take that $_GET information and decide which include to use. It could also have a default include (one of those two or another or none) if neither is specified.

You could use javascript and AJAX to load in content from another page. But with a slide show it could get tricky making it function once it got there. Most slide shows require that they initialize on page load. If you bring in the content after that via AJAX, it's too late.

Generally these issues can be worked out. But it's as you say:


I have looked at many scripts etc to change content on a page and none of them make no sense to me

. . . not simple.

Tim Dobson
04-05-2010, 07:25 PM
Ah right so to save all the heart ache i would probably be better off creating a seperate page for the list and for the slide show and just redirect if the user wants to use one or the other.