title: My jquery code that access a csv file missws some names depending onthe search string
body: <pre><code>This code is from my page at http://www.rootsweb.ancestry.com/~nmscgs2/obit_page.htm.
  </code></pre>
  
  <p>When executing a search certain names are not found in the csv file. Changing the search string has varied results. For instance there are two Gilliand names in the csv file but only one is found when using part or all of the name in the search textbox. I have tried different methods of string matching with the same results</p>
  
  <pre><code>&lt;script type="text/javascript" src="jquery.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
  function searchOnFocus1(){
  var searchbox;
           searchBox = document.getElementById('inputstring');
  
          if(searchBox.value == "Last Name")
          {
  
                  searchBox.style.fontStyle = "normal";
                  searchBox.style.color = "#000000";
                  searchBox.value = "";
                  }
  }
  var inputstr; 
  function showResult(str)
  {
  document.getElementById("inputstring").value = str;
     $("#tblCustomers").find("tr:not(:first)").remove(); // clear existing table
     if (!document.getElementById("inputstring").value)
  {
      alert("Enter a Valid Input");
      document.getElementById("inputstring").value = "Last Name";
      //inputstring.focus();
      return;
  }
  
  inputstr=str;
  
     $.get("obit_list.csv", function(data, status)
     {
  
        if (status = "success")
        {
            // window.alert("Obit File Loaded");
        }
        else
        {
           window.alert("Obit file not found");
        }
  
        var tbl = document.getElementById("tblCustomers"); // could be var tbl = $("#tblCustomers");
        var tbody = document.getElementById("ObitData");
        // get table body by name
        var allRows = data.split(/\r\n|\r/);
        // split data at line feed
  
        for (var singleRow = 0; singleRow &lt; allRows.length;
        singleRow ++ )
        {
  
           var rowCells = allRows[singleRow].split(',');
           var str = rowCells.toString();
           // window.alert(str);
           var length = inputstr.length;// get length of input box string for matching
           var s = str.slice(0,length); // first letters of last name in obit file
            //window.alert(s)
            if (s.toLowerCase( ) == inputstr.toLowerCase( ))// do names starting with input string only
           {
              // window.alert(s)
  
              var tr, td;
              tr = tbody.insertRow(tbody.rows.length);
              tr.align = "center";
              for (var rowCell = 0; rowCell &lt; rowCells.length;
              rowCell ++ )
              {
                 td = tr.insertCell( - 1);
  
                 td.innerHTML = rowCells[rowCell];
              }
  
           }  // end of if statement
          else
           {
              singleRow ++
           }
  
  
        }
  
     }
     );
  </code></pre>