Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > combox not showing same records every time

Reply
Thread Tools

combox not showing same records every time

 
 
hygum
Guest
Posts: n/a
 
      03-03-2007
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?

 
Reply With Quote
 
 
 
 
OmegaJunior
Guest
Posts: n/a
 
      03-03-2007
On Sat, 03 Mar 2007 07:54:00 +0100, hygum <(E-Mail Removed)> wrote:

> 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".

--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
 
Reply With Quote
 
 
 
 
hygum
Guest
Posts: n/a
 
      03-03-2007
On 3 Mar., 08:27, OmegaJunior <(E-Mail Removed)> wrote:
> On Sat, 03 Mar 2007 07:54:00 +0100, hygum <(E-Mail Removed)> wrote:
> > 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".
>
> --
> Using Opera's revolutionary e-mail client:http://www.opera.com/mail/


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

 
Reply With Quote
 
j.andersen
Guest
Posts: n/a
 
      03-05-2007
On Mar 3, 8:54 am, "hygum" <(E-Mail Removed)> wrote:
> 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

 
Reply With Quote
 
hygum
Guest
Posts: n/a
 
      03-06-2007
On 5 Mar., 11:17, "j.andersen" <(E-Mail Removed)> wrote:
> On Mar 3, 8:54 am, "hygum" <(E-Mail Removed)> wrote:
>
> > 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

 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Explorer.exe error report every time access every type of video me =?Utf-8?B?SXJ3YW5zeWFo?= ASP .Net 4 10-30-2007 07:49 AM
Datagrid not showing records on production server syedrafey@gmail.com ASP .Net 1 04-10-2006 08:18 AM
Want to set a value of a combox, using a string SpiderFly Javascript 2 09-22-2005 06:41 PM
Showing only 10 records at a time Janusz Jasinski XML 1 08-04-2003 01:07 PM
MIP combox Thomas B VOIP 0 07-22-2003 08:04 AM



Advertisments