TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 04-03-2010, 02:56 PM   #1 (permalink)
The Contributor
 
Tim Dobson's Avatar
 
Join Date: Feb 2010
Posts: 69
Thanks: 16
Tim Dobson is on a distinguished road
Default Form menu help :(

Ok straight to business we wont mention the queen!

I have a list menu:

PHP Code:
<select name="mydropdown">
  <
option value="List">View as list</option>
  <
option value="Show">View as slide-show</option>
</
select
meh thats it really. What i need it to do is change what is on the page when its changed. So as an example could someone show me how i would just go about changing a bit of text depending on which option it is on please? i have looked at loads of examples and all of them increased my confusion state lol :D thanks
Tim Dobson is offline  
Reply With Quote
Old 04-03-2010, 04:31 PM   #2 (permalink)
The Addict
 
Join Date: May 2009
Posts: 287
Thanks: 5
adamdecaf is on a distinguished road
Default

There is a simple way to do this.

html4strict Code:
<select name="mydropdown" onchange="change_content(this.options[this.selectedIndex].value);">
  <option value="List">View as list</option>
  <option value="Show">View as slide-show</option>
</select>

javascript Code:
function change_content(id, element) {
  // alert(id);

  // Now that we have the id we can grab documents with an XHR or
  // just change the content here.
 
  // For example if _element_ is an ID from an HTML Element
  var elm = document.getElementById(element);

      elm.innerHTML = id;

  // Or...
  // Remember, IE doesn't support this function.
  var xhr = new XMLHttpRequest();
      xhr.open('GET', 'http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=' + encodeURIComponent(id), false);
      xhr.send(null);

  // Now just parse the json
  // You should use this script.
  // [url]http://json.org/json2.js[/url]
  var response = JSON.parse(xhr.responseText);

  // And then fill the element
  var n = 0, count = response.length;
  while (n < count) {
     elm.innerHTML += ....
     n++;
  }

}
__________________
My Site
adamdecaf is offline  
Reply With Quote
Old 04-03-2010, 06:22 PM   #3 (permalink)
The Contributor
 
Tim Dobson's Avatar
 
Join Date: Feb 2010
Posts: 69
Thanks: 16
Tim Dobson is on a distinguished road
Default

ok so i dont know if im 1 step closer or not... its all jibberish to me lol.

what if i just want it to pull out the include ?

on View as list option i need it to do:
PHP Code:
<?php include ("includes/list.php");?>
and on View as slide-show option i need it to do
PHP Code:
<?php include ("includes/slideshow.php");?>
Tim Dobson is offline  
Reply With Quote
Old 04-03-2010, 07:14 PM   #4 (permalink)
The Addict
 
Join Date: May 2009
Posts: 287
Thanks: 5
adamdecaf is on a distinguished road
Default

Where did the includes come from? The code that I posted above needs to be loaded on the same page [after it is completed] (how ever it's done doesn't matter).
__________________
My Site
adamdecaf is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Form to submit to another form patmagpantay General 8 07-21-2008 07:42 AM
Menu Display Problem in IE6+ obolus XHTML, HTML, CSS 14 03-01-2008 07:57 PM
Some help with dropdown menu Tanax Javascript, AJAX, E4X 2 02-18-2008 04:38 PM
Menu using 2 js functions. Sam Granger Javascript, AJAX, E4X 0 11-15-2007 01:26 PM
Form Processing William Tips & Tricks 8 04-17-2005 03:24 PM


All times are GMT. The time now is 09:25 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design