Current location: Hot Scripts Forums » Programming Languages » PHP » Drop down list change PHP


Drop down list change PHP

Reply
  #1 (permalink)  
Old 01-28-05, 12:17 PM
ancdy ancdy is offline
Newbie Coder
 
Join Date: Jan 2005
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Drop down list change PHP

How can i make a drop down list, which when an option is selected, a small piece of PHP code will change.
For example, i have a number of different categories, in a news system (Cute News, most of you will probably know about it). To display the news from a certain category, you enter a small line of code into the PHP insert news code, which specifies the category. I want the visitor to be able to select a category from the drop down list, and for in a table below that, the news from that category to show.

So, all I really need is to be able to specify what code is to be displayed in the table for each value in the drop down list.

Hope this makes sense

Does anyone have any ideas, or code which does this?

Thanks.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 01-28-05, 02:29 PM
End User's Avatar
End User End User is offline
Level II Curmudgeon
 
Join Date: Dec 2004
Posts: 3,027
Thanks: 14
Thanked 35 Times in 33 Posts
Quote:
Originally Posted by ancdy
How can i make a drop down list, which when an option is selected, a small piece of PHP code will change.
For example, i have a number of different categories, in a news system (Cute News, most of you will probably know about it). To display the news from a certain category, you enter a small line of code into the PHP insert news code, which specifies the category. I want the visitor to be able to select a category from the drop down list, and for in a table below that, the news from that category to show.

So, all I really need is to be able to specify what code is to be displayed in the table for each value in the drop down list.

Hope this makes sense

Does anyone have any ideas, or code which does this?

Thanks.
You can't really do this in PHP, but you can in Javascript with this wonderful little bit of code from Matt Kruse:

www.mattkruse.com/javascript/dynamicoptionlist/
__________________
I don't live on the edge, but sometimes I go there to visit.
-------------------------------------------------------------------------
Sanitize Your Data | Oracle Date & Substring Functions | Code Snippet Library | [url=http://www.codmb.com/Call Of Duty[/url]
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 02-07-05, 06:37 AM
php~pro php~pro is offline
Wannabe Coder
 
Join Date: Jun 2004
Location: In a nice house.
Posts: 132
Thanks: 0
Thanked 0 Times in 0 Posts
I beg to differ. This can be done with php/pear or via using php/JavaScript (JSRS) without the need for a full browser recall.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 02-09-05, 05:48 AM
liljoeyjordison liljoeyjordison is offline
Newbie Coder
 
Join Date: Jan 2005
Posts: 85
Thanks: 0
Thanked 0 Times in 0 Posts
What would be the simplest way to have a drop down menu which when an option is selected changes the value of a variable... I've seen many ways of doing this in a number of different languages, but do any of you know (preferably) php based way of doing this?

[Code examples please, I'm a big n00b ; ) ]
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 02-09-05, 04:33 PM
php~pro php~pro is offline
Wannabe Coder
 
Join Date: Jun 2004
Location: In a nice house.
Posts: 132
Thanks: 0
Thanked 0 Times in 0 Posts
By far the simplest solution would be DHTML (JavaScript). Tyr googling for chained selectors, dhtml dropdowns, dynamic dependant list menus etc and you should find a whole load of results. My advice would be to find a tutorial to help you understand the programming logic and learn some code.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 02-10-05, 06:33 AM
liljoeyjordison liljoeyjordison is offline
Newbie Coder
 
Join Date: Jan 2005
Posts: 85
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by php~pro
By far the simplest solution would be DHTML (JavaScript). Tyr googling for chained selectors, dhtml dropdowns, dynamic dependant list menus etc and you should find a whole load of results. My advice would be to find a tutorial to help you understand the programming logic and learn some code.
Thanks, I'll try that right away
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
retrieve information from MYSQL through drop down list minglou PHP 3 04-03-09 10:43 PM
Please help the drop down list! minglou PHP 4 08-23-04 10:47 PM
Create List with PHP ...? demnos PHP 6 08-13-04 03:40 PM
month drop down list angela JavaScript 2 03-31-04 03:33 AM
PHP script to change URL link weekly hculbert Script Requests 0 01-23-04 04:48 PM


All times are GMT -5. The time now is 06:44 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.