Results 1 to 3 of 3

Thread: List/Menu changing my content

  1. #1
    Join Date
    Apr 2010
    Posts
    9
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default List/Menu changing my content

    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 Code:
    <?php include ("includes/slideshow.php");?>
    Ok so that is a success.

    Now i have a drop-down menu

    Code:
    <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 Code:
    <?php include ("includes/mylist.php");?>
    instead of
    PHP Code:
    <?php include ("includes/slideshow.php");?>
    and if you selected View as slideshow in the drop-down it needs to be
    PHP Code:
    <?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

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    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.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Apr 2010
    Posts
    9
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default

    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.

Bookmarks

Posting Permissions

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