?
Solved

PHP bropdown menu question

Posted on 2005-04-17
8
Medium Priority
?
417 Views
Last Modified: 2010-08-05
There are certain dropdown menus that also allow a visitor to ener information into the menu, such as when a website request your state. You can dropthe menu down and choose a state or enter Tex and tab to the next field. The program will fill in Texas for you. Is this a PHP or JS style menu. If it's PHP does anyone have some sample code on how it works. I am familiar with how to code standard drop down menus.
Thanks,
Michael
0
Comment
Question by:mhoggatt1
  • 5
  • 2
8 Comments
 
LVL 14

Expert Comment

by:cracky
ID: 13802822
Are you talking about using an "Other ..." option in your select list and getting user input from the text field instead of the dropdown? Can you provide an example of what you mean?

If you just want to get info from the text field if other is selected, then it's pretty straightforward:

<?php
if (array_key_exists($_POST['option'])) {

  if ($_POST['option'] == "other") {

    // do something with the text field

  }

}
?>
0
 
LVL 14

Expert Comment

by:cracky
ID: 13802833
Oops, early morning code:

<?php
if (array_key_exists('option' , $_POST)) {

  if ($_POST['option'] == "other") {

    // do something with the text field

  }

}
?>

Note, you can also use:
if (isset($_POST['option'])) {
0
 

Author Comment

by:mhoggatt1
ID: 13802887
Actually it's a dropdown menu I'm looking at. The dropdown menu is a list of the books of the Bible. You can select Genesis from the nemu or type in Gen in the dropdown bos itself and hit OK and the program fills in the rest of the word for you. It's on my personal computer, wish I could let you see how it owrks. I'll check your code out tomorrow and see it it's what I'm looking for.
Thanks,
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 14

Expert Comment

by:cracky
ID: 13802936
Most dropdown menus in browsers already work like that. If you select the menu and start typing a word, it will skip to the corresponding item. If you are looking for a menu that autofills suggestions based on what you type (like Google Suggest http://www.google.com/webhp?complete=1&hl=en), then that is definitely a JavaScript / DHTML solution (and a relatively complex one at that).

An article that discusses the method:

http://www.adamstiles.com/adam/2004/12/hacking_google_.html
0
 
LVL 32

Accepted Solution

by:
ldbkutty earned 1000 total points
ID: 13803201
0
 
LVL 14

Expert Comment

by:cracky
ID: 13803271
I am doubtful as to the functionality of autofill boxes unless they actually populate the layer by making a call to an asynchronious request to a database (i.e. without reloading the page).

If you are hard coding JS values into a text box, then you are just simulating functionality already built in to most browser select boxes.

Much more useful is the ability to make this request without reloading the page using XMLHttpRequest. Although this is not the easiest technique to master and you do need to be an experienced programmer to understand the technology and implement it usefully.

Also see here for an outline:

http://www.adaptivepath.com/publications/essays/archives/000385.php
0
 

Author Comment

by:mhoggatt1
ID: 13803332
Hi guys,
   I've looked at some of the links you sent. What I'm looking for doesn't have a textbox and a dropdown menu, only the dropdown menu. The dropdown menu itself actually allows you to enter data right into the menu area or select it's menu items. I"ve never seen this before. Somehow it takes the Gen and compares it somehow and finds Genesis then loads the page. I couls split the dropdown menus into Old and New Testament, that way the menus wouldn't be as long.
Thanks,
0
 
LVL 14

Expert Comment

by:cracky
ID: 13803342
What's the advantage of that over a normal select box which jumps to the item in the list when you start typing?
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The title says it all. Writing any type of PHP Application or API code that provides high throughput, while under a heavy load, seems to be an arcane art form (Black Magic). This article aims to provide some general guidelines for producing this typ…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses
Course of the Month13 days, 16 hours left to enroll

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question