Gossamer Forum
Home : Products : DBMan : Customization :

search options, dropdown list

(Page 1 of 2)
> >
Quote Reply
search options, dropdown list
Hello there!!Smile

I have a difficult question,
Say i fill in the words for a search
(Name) => jansen
(City) => Duelft
(This city name doesn't excist because it has to be "Delft")
After pressing "search" ,you get a new page that explains that the city name isn't ok. It tells you that you have to fill in the first letter of the city (that is in our example "d") and press "Search" again.
-Now- you get a dropdownlist with all city names starting with a "d".
You can select "delft" again a press "Search" .Now it will find your searchinput.

How can i do this and is this possible.

greetings,
[removed by request]
The Netherlands (Europe)

(example site url deleted!)

Quote Reply
Re: search options, dropdown list In reply to
The site you referred to uses javascript. I don't know how to program javascript. Maybe someone else will have an idea.

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: search options, dropdown list In reply to
They only use the javascript to check if there is any valid input in the fields.
So the do something in the ".pl" file
mmmmh.......

greetings,
[removed by request]
The Netherlands (Europe)

Quote Reply
Re: search options, dropdown list In reply to
I thought I was following your instructions the first time, but everytime I entered something into a field I got an error message.

Anyway -- let's see if I can figure this out.

Basically, if the user enters just one letter in the city field, he gets a form back with the cities that start with that letter in a select field. (I tried it on that other site, just putting a letter in to start with. I got the select field with the cities listed.)

What happens if there are no cities that match that letter?

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: search options, dropdown list In reply to
Hello Hobo,
Because our English is very badly, we want too say something in Dutch.

Bovenstaande is natuurlijk een geintje.
Allereerst moet je databasemogelijkheden hebben. Noem eens een MySQL. Vervolgens filter je met javascript de nodige fouten uit de userinput...altijd dubbelchecken met script immers!!! (sommige browsers ondersteunen javascript niet zoals je weet)
Regel een lijst met alle nederlandse plaatsnamen, bak een fatsoenlijk script en geef de user een combobox met mogelijkheden.
Zo simpel is het.

kijk bijvoorbeeld eens op www.06-nummer.nl
Beter goed gekopiŽerd dan slecht gejat.

Groet,
Rogier Janssen uit Duelft.

n.b. we zitten ook in Delft, heb je nog vragen dan kun je gerust even bellen



Quote Reply
Re: search options, dropdown list In reply to
Hello Deni,

==What happens if there are no cities that match that letter?==
I have a predefined list of ALL cities, (a total of 3500 !)
So i have a option list starting with "a", "b",....
If they fill in "Dulft" instead of "Delft" then they get the option-field starting with "D".
If they fill in "Felft" ,starting with a "F" ,they get the option-field with all cities starting with a "F".
So, there is always a city to choose from,(when they see the optionlist starting with "f" they know they did someting wrong.. Smile

greetings,
[removed by request]
The Netherlands (Europe)




Quote Reply
Re: search options, dropdown list In reply to
Do you have cities that begin with the letter "X"?


JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: search options, dropdown list In reply to
No, thats the only letter with no citynames,but when they fill in a Cityname starting with "x" they should get a errormessage telling them that there are no cities starting with "x".Wink

greetings,
[removed by request]
The Netherlands (Europe)

Quote Reply
Re: search options, dropdown list In reply to
Okay. I really need to have as much as possible from you. Every time I guess at what someone wants, I guess wrong and I have to rewrite the code I gave them. Smile

The user has entered a last name and a city. There are no records returned, which means we are now in sub html_view_failure. First, the script needs to look at what the input in the city field was. There are several options.

1 -- The city name exists in the database. In that case, the city name is entered back into the search form.

2 -- The city name does not exist in the database. In that case, the city name field remains blank. A message is printed to say that the user can just enter the first letter of a city.

3 -- The city name was actually only a single letter. In that case, the city name field becomes a drop-down list of all city names in the database that begin with that letter. If the letter is "X," then there is a message that there are no cities that start with that name and they get an empty text field to enter another city or letter.

Is this all correct?

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: search options, dropdown list In reply to
I try to explain it as good as i can.

I think that everything you've written is OK!

First:
I have -all- names of cities in the Netherlands because there are 3500 cities in The Netherlands i have split this list in different lists, so a list with cities starting with "a" ,"b", and so on.
These lists are .txt files(perhaps you need this also?,so if a write about "searching the lists" it is because i don't know how to do it... ).
because of the speed of the script i can't make a optionfield with all citynames (3500!) in alfhabetic order.
and i don't want a select-option-field in my first search page.First the user can fill in the city
So a user only can search for those cities that already are predefined in my lists, but they don't see it at the first search page

1 -- The city name exists in the database. In that case, the city name is entered back into the search form
=====>User entered his/her last name and a city.
The database will check if the city name excists in one of the lists I made, so if user fills in "delft" (this is a good cityname) the database checks the citynamelist (d.txt),and in this case, the name "delft" is in the list d.txt ,so the search is OK and you get the output records.(instantly..)Smile


2 -- The city name does not exist in the database. In that case, the city name field remains blank. A message is printed to say that the user can just enter the first letter of a city.
===>User entered his/her last name and a city.
If users enters "dulft" (or "fulft" or "gulft"...these citynames are wrong, because it's "delft") the database searches the lists d.txt. This name is not in the list so they get a new page(a html_view_failure?) with a message that this city is not a valid cityname and
*****IF THIS IS POSSIBLE->the city name field becomes a drop-down list of all city names in the database that begin with the letter "d" .*******
otherwise if the above isn't possible:
that they can fill in the first letter of the city (the city field is left blank on this page),so they get a new page and there is a option field with all the cities beginning with "d".

3 -- The city name was actually only a single letter. In that case, the city name field becomes a drop-down list of all city names in the database that begin with that letter. If the letter is "X," then there is a message that there are no cities that start with that name and they get an empty text field to enter another city or letter.
==>User entered his/her last name and and only the first letter of a city.
This is OK.Smile


I think everything is correct !!


greetings,
[removed by request]
The Netherlands (Europe)


Quote Reply
Re: search options, dropdown list In reply to
I'm still not willing to write code for this until we get it all straightened out. Smile

Where are these lists of city names? In the same directory as DBMan? In a subdirectory? Some place else on your server?

In Reply To:
the database checks the citynamelist (d.txt),and in this case, the name "delft" is in the list d.txt ,so the search is OK and you get the output records.
Except in my post, this search was still not a successful search because there was no name that matched in that city. Or there were too many names. All I am concerned with here is search failures.

In Reply To:
*****IF THIS IS POSSIBLE->the city name field becomes a drop-down list of all city names in the database that begin with the letter "d" .*******
Possible, but probably not what you want. In the examples you gave, you included misspellings of "fulft" or "gulft." If the person wanted "Delft," but typed in "gulft," he would get a list of "G" cities -- and he would not be able to enter the city he really wanted.

You know, another way of going about this would be to have a preliminary search page where the user first enters the starting letter of the city. Then he would get the search form where he could input the last name and a select list of the cities that matched the starting letter he wanted in the first place.

Still another possibility is to have two select lists -- the first one has letters of the alphabet. The second one is filled in via javascript with cities that start with that letter. I don't normally do javascript, but I found some "cut-and-paste" code that looks like it might not be too hard to convert. If you'd like to see an example of what I'm talking about, go to http://javascript.internet.com/forms/country.html. The only disadvantage is that I think the user would have to select the letter and city again if the search was unsuccessful.


JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: search options, dropdown list In reply to
Hello again.Blush

The lists of the citynames are in the same directory as DBMan.

In Reply To:
Except in my post, this search was still not a successful search because there was no name that matched in that city. Or there were too many names. All I am concerned with here is search failures.
You're right, if user fills in good cityname and a lastname,but there are to many results ,say more than 30, you also get a message to narrow the search with a firstname.But if there are less than 30 you get the results shown.

In Reply To:
Possible, but probably not what you want.
yes you are again rightSmile.

so lets keep it like you posted before==>
In Reply To:
2 -- The city name does not exist in the database. In that case, the city name field remains blank. A message is printed to say that the user can just enter the first letter of a city.

This is better.. (i was working at night yesterday, perhaps i didn't see this,stupid of me...)

Please no javascript.

greetings,
[removed by request]
The Netherlands (Europe)


Quote Reply
Re: search options, dropdown list In reply to
Hello,
Also, what is the best way to write all citynames in the file?
Just one long line with a "," in between?

greetings,
[removed by request]
The Netherlands (Europe)

Quote Reply
Re: search options, dropdown list In reply to
No. The best way is to put each city name on one line.

I'm going to have to think about the best way to go about this. Give me some time. Smile

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: search options, dropdown list In reply to
ok ,thank youSmile
I make my lists... pfffff 3500 names

greetings,
[removed by request]
The Netherlands (Europe)

Quote Reply
Re: search options, dropdown list In reply to
hello JPDeni Smile & Blush

Do you already know how to fix my problem?

greetings,
[removed by request]
The Netherlands (Europe)

Quote Reply
Re: search options, dropdown list In reply to
I was waiting until you got the city names files created. What is the format of the names of the files? Are they all in one directory? Is it the same directory as the DBMan scripts?

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: search options, dropdown list In reply to
Hello JPDeni,

I have finished my city names files.
My DBMan is in my cgi-bin (www.example.com/cgi-bin/db.cgi)
The name-files are also in the cgi-bin (www.example.com/cgi-bin/a.txt)
so city names starting with a "a" in the file "a.txt"

greetings,
[removed by request]
The Netherlands (Europe)

Quote Reply
Re: search options, dropdown list In reply to
Hello JPDeni,

mmhBlushBlushBlush:)
Do you already know how to fix my problem?

greetings,
[removed by request]
The Netherlands (Europe)


Quote Reply
Re: search options, dropdown list In reply to
Sorry.

You know what? I think it *would* be better just to give the user the select list with cities that start with the first letter of the city he entered. If he entered the wrong first letter, he can use the back button on the browser to get the previous form. I really think that would be the best thing.

Remember that we are only dealing with search failures here.

Add this to the beginning of sub html_view_failure:

Code:

if ($in{'City'}) {
$city_start = lc(substr($in{'City'},0,1));
if ($city_start eq 'x') {
$in{'City'} = '';
}
else {
open (CITY, "$db_script_path/$city_start.txt") or
&cgierr("error in view_failure. unable to open city file: $db_script_path/$city_start.txt.\nReason: $!");
@cities = <CITY>;
close CITY;
foreach $city (@cities) {
chomp $city;
if (lc($city) eq lc($in{'City'})) {
$city_found = 1;
last;
}
}
unless ($city_found) {
$in{'City'} = '';
$message .= qq|The city name you entered was incorrect. Choose the city from the list below or
use the "Back" button on your browser to go back to the previous form.|;
$city_select = qq|<SELECT name="City">|;
foreach $city (@cities) {
$city_select .="<option>$city\n";
}
$city_select .= "</select>";
}
}
}
Be sure to change every instance of City to match the name of the field in your database.

In sub html_record_form, where you have your City field, change it to

Code:

|;
if ($city_select) { print $city_select; }
else {
print qq| your current City input field |;
}
print qq|
I think this should work. Give it a try and see.

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: search options, dropdown list In reply to
hello JPDeni,

This is working great! but,
i don't get the error message "unless....." when a city-input is wrong.
Perhaps use of db.cgi?

greetings,
[removed by request]
The Netherlands (Europe)

Quote Reply
Re: search options, dropdown list In reply to
In Reply To:
This is working great! but,
If there's a "but" it ain't working!! Smile

You're not getting the select field with the city names?

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: search options, dropdown list In reply to
Hello JPDeni,
OK lets explain what happens,
in my database is a name="jansen" in city="delft"
I've made citynames-lists like a.txt, b.txt ...
In the d.txt there a names like:

DELFSTRAHUIZEN
DELFT (our example)
DELFZIJL


When i search for the name "jansen" in "delft" i get the results.=>this is working!
when i seach for the name "jansen" in "dulft" i get a new page WITH the select box (=>this is working!Smile)BUT no error message.instead i get the default error
"There were problems with the search. Reason: no matching records.
Please fix any errors and submit the record again."

i can't get it right to show the error you've made in the script.

greetings,
[removed by request]
The Netherlands(Europe)




Quote Reply
Re: search options, dropdown list In reply to
It may be a matter of where you are placing the code.

Make sure it's after

my ($message) = $_[0];

in sub html_view_failure.

JPD
http://www.jpdeni.com/dbman/
Quote Reply
Re: search options, dropdown list In reply to
stupid meBlush!

i've fixed it....stupid...stupid me

greetings,
[removed by request]
The Netherlands (Europe)

> >