![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Apr 2005
Posts: 1
Rep Power: 0
![]() |
drop down menus, forms and php
Hi there,
I've just managed to get a dependent drop down menu working on a website using the code found here: http://www.zend.com/zend/tut/drop-down.php The menu is for an Automotive site so it works by make and model of vehicles. My problem is, I can't get an "Any Make" or "Any Model" option to work. If i set the menu option to have no value, it returns this address: localhost/dfm/auto/carview.php?make=&model=&minprice=&maxprice=[/url] and no records are loaded. However, on similar websites I have seen, when the "Any Model" option is selected, the model paremeter does not appear in the address ie: localhost/dfm/auto/carview.php?make=whatever&minprice=&maxprice=[/url] So my question is, how do I make the form return nothing for that particular menu if that "any..." value is selected? |
|
|
|
|
|
#2 |
|
Programming Guru
![]() |
localhost/dfm/auto/carview.php?make=&model=&minprice=&maxprice= looks like you need some values to those parameters you are passing at the minute all you are doing is sending it empty parameters. |
|
|
|
|
|
#3 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
Simple:
[php]if ($_GET['make']) { // the variable exists and contains something } else if (isset($_GET['make'])) { // the variable exists, but does not contain anything } else { // the variable does not exist }[/php] |
|
|
|
|
|
#4 |
|
Programmer
Join Date: Jan 2005
Location: Bayamon, Puerto Rico
Posts: 71
Rep Power: 4
![]() |
You can make your code works as you like in two forms... you can set a value to the Any Model... like lets say "all" so when the variable is send... it has a value of all and you can tap it on the form processing script... the second way is to send the value empty as you are right now and tap the empty value (isset does not test that, it will return true if the variable exists not mattering if it is empty or not) you have to compare it to an empty string or with the empty() function... (if you decide to use the latter... consider that some browsers send the name in the drop box if there is no value set)...
hope that i had been of aid ![]() -codetaino
__________________
"God bless u all" :) Last edited by codetaino; Apr 8th, 2005 at 12:05 AM. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|