A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: search word list

  1. #1
    Senior Member creekmonkey's Avatar
    Join Date
    Jul 2006
    Posts
    121

    search word list

    I have a large word list. What would be the best way to search this list to see if the contents of an edit box msatches any words in the list.

    I have tried adding the words to an array and searching

    for (i=0;i<words.length;i++){
    if(edit_box==words[i]){
    edit_box2=OK}
    else{edit_box2=not ok}

    this doesnt work.

    any help is aprieciated.

  2. #2
    Member
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    76
    You have simply forgotten the "" to declare a string

    edit_box2 = OK

    must be:
    edit_box2 = "OK"

    Full version
    Code:
    for (i=0;i<words.length;i++){
    if(edit_box==words[i]){
    edit_box2="OK"}
    else{edit_box2="not ok"}

  3. #3
    Senior Member creekmonkey's Avatar
    Join Date
    Jul 2006
    Posts
    121
    It only works if edit_box is equal to the last word in the array.

  4. #4
    Member
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    76
    yepp, it's because your loop must be stopped if a right value is found. Otherwise it will set the edit_box back to "not ok".

    Code:
    for (i=0;i<words.length;i++){
    if(edit_box==words[i]){
    edit_box2="OK"
    break;}
    else{edit_box2="not ok"}
    Now it should work.

  5. #5
    Senior Member creekmonkey's Avatar
    Join Date
    Jul 2006
    Posts
    121
    Thanks leifi, that solved the problem.

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center