basic list search, js issue

Results 1 to 2 of 2

Thread: basic list search, js issue

  1. #1
    Heaven's Martini Guest

    Default basic list search, js issue

    Well,<BR><BR>this is a js question amongst my asp pages.<BR><BR>I have some crappy list search code evidently. It used to work,but not well, but it was with very simplistic data, however now, i have to select lists to search based on the onKeyUp event of a text box. <BR><BR>The two lists contain an id, and ssn and the other a name, these two lists are dependent on each other (id in each list matches the other) I want to search both lists onKeyUP, that part is quite simplistic actually, if the user types in an ssn, it will cruise the ssn list and then switch both lists to be selected for the match.<BR><BR>I won&#039;t bother with the js code ,<BR>its basic, it runs a for loop of the entries in the select list,<BR>the part i do not understand is how could I match the textbox entry with the select list selectedIndex text property?<BR><BR>the matching scheme in the old code is<BR>form.selectlist.options[i].text.toUpperCase().indexof(textboxvalue) == 0)<BR><BR>it doesnt seem to work, I still need to super debug but the list search works but it seems to take a letter T and go to the C&#039;s in the list (only 3 entries)<BR><BR>I want to search for an exact match, not a incorrect match.<BR><BR>anyone come across this simplistic of code before.

  2. #2
    Join Date
    Dec 1969

    Default Looks okay to me...

    ...I think it is, as you noted, debug time.<BR><BR>I presume you&#039;ve already done toUpperCase on the text input in order to make this match?<BR><BR>It&#039;s cute code. I probably would have done <BR><BR>form.selectlist.options[i].text.toUpperCase().substring(0,testboxvalue.lengt h)==testboxvalue<BR><BR>This is simpler. Should be faster, as substring would have to keep creating junk strings and then tossing them away.<BR><BR>Hope you figure it out!<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts