combox not showing same records every time

H

hygum

I have a combobox on this testsite: sneleopard.dk/combobox.html
it should show all records containing the search string while typing.
But sometimes it only shows some of them, why?
1) type "spi" and it shows among others "spinat helbladet"
2) delete the search string and type "bla"
3) it should now among others show "spinat helbladet" again, but it
doesnt, why?

maybe its because that the function shows first records starting with
the search string, and thereafter those containing?
 
O

OmegaJunior

I have a combobox on this testsite: sneleopard.dk/combobox.html
it should show all records containing the search string while typing.
But sometimes it only shows some of them, why?
1) type "spi" and it shows among others "spinat helbladet"
2) delete the search string and type "bla"
3) it should now among others show "spinat helbladet" again, but it
doesnt, why?

maybe its because that the function shows first records starting with
the search string, and thereafter those containing?

It's a problem with the commas. Try it with "baby" or "frisk": you won't
find "spinat, baby, frisk".
 
H

hygum

It's a problem with the commas. Try it with "baby" or "frisk": you won't
find "spinat, baby, frisk".

yes I do. With baby or frisk i find that record. The commas are
escaped in the javascript array. But still it can be a comma
problem... I will try without
 
J

j.andersen

I have a combobox on this testsite: sneleopard.dk/combobox.html
it should show all records containing the search string while typing.
But sometimes it only shows some of them, why?
1) type "spi" and it shows among others "spinat helbladet"
2) delete the search string and type "bla"
3) it should now among others show "spinat helbladet" again, but it
doesnt, why?

I changed your function, so that the array search is done once in one
loop only and it gives me none of the problems above.

Code:
for(i = 0; i < functionListLength; i++)
{
if( ( functionlist[i].search(re1) >= 0 ) ||
( functionlist[i].search(re2) >= 0 ) )
{
selectObj[numShown] = new Option(functionlist[i],comboids[i]);
numShown++;
}
}

You will have to clean up the variables not used, like
"visteelementer".

In my opinion you can leave out the first criteria (first search) as
the second criteria will find also those who starts with the search
string!

Best wishes,
John, Latvia
 
H

hygum

I have a combobox on this testsite: sneleopard.dk/combobox.html
it should show all records containing the search string while typing.
But sometimes it only shows some of them, why?
1) type "spi" and it shows among others "spinat helbladet"
2) delete the search string and type "bla"
3) it should now among others show "spinat helbladet" again, but it
doesnt, why?

I changed your function, so that the array search is done once in one
loop only and it gives me none of the problems above.

Code:
for(i = 0; i < functionListLength; i++)
{
if( ( functionlist[i].search(re1) >= 0 ) ||
( functionlist[i].search(re2) >= 0 ) )
{
selectObj[numShown] = new Option(functionlist[i],comboids[i]);
numShown++;
}}

You will have to clean up the variables not used, like
"visteelementer".

In my opinion you can leave out the first criteria (first search) as
the second criteria will find also those who starts with the search
string!

Best wishes,
John, Latvia

i know the second search find the same as the first (but not the
reverse), but thats because i want the list to be first the records
that begins with the search string, and thereafter the records that
contains.

Thanks for your help
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top