combox not showing same records every time

Discussion in 'Javascript' started by hygum, Mar 3, 2007.

  1. hygum

    hygum Guest

    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?
    hygum, Mar 3, 2007
    #1
    1. Advertising

  2. hygum

    OmegaJunior Guest

    On Sat, 03 Mar 2007 07:54:00 +0100, hygum <> 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/
    OmegaJunior, Mar 3, 2007
    #2
    1. Advertising

  3. hygum

    hygum Guest

    On 3 Mar., 08:27, OmegaJunior <> wrote:
    > On Sat, 03 Mar 2007 07:54:00 +0100, hygum <> 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
    hygum, Mar 3, 2007
    #3
  4. hygum

    j.andersen Guest

    On Mar 3, 8:54 am, "hygum" <> 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
    j.andersen, Mar 5, 2007
    #4
  5. hygum

    hygum Guest

    On 5 Mar., 11:17, "j.andersen" <> wrote:
    > On Mar 3, 8:54 am, "hygum" <> 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
    hygum, Mar 6, 2007
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Janusz Jasinski

    Showing only 10 records at a time

    Janusz Jasinski, Aug 4, 2003, in forum: XML
    Replies:
    1
    Views:
    387
    Gill Bates
    Aug 4, 2003
  2. Affan Syed
    Replies:
    4
    Views:
    413
    Stephan Br?nnimann
    Nov 19, 2004
  3. John Fly
    Replies:
    4
    Views:
    350
    =?ISO-8859-1?Q?Arne_Vajh=F8j?=
    Mar 12, 2007
  4. =?Utf-8?B?SXJ3YW5zeWFo?=
    Replies:
    4
    Views:
    2,437
    =?Utf-8?B?SXJ3YW5zeWFo?=
    Oct 30, 2007
  5. SpiderFly
    Replies:
    2
    Views:
    74
    SpiderFly
    Sep 22, 2005
Loading...

Share This Page