[font=times new roman]I am trying to make a little script that allows a user to search for blocks of text within strings. The user enters data into form fields and he or she can enter text into another form field (needle) to search the data fields (haystack). When the search string matches something in the data fields the associated data fields are highlighted in a yellow background color.
Right now the search string is acting funny. W[/font]hen I enter a search string I get no highlighting unless if the first character(s) of the search string are the same as the first character(s) for the items. For instance, If I search for the text “at” in the word “bat” I will not get any yellow highlighting. But I would get highlighting for “bat” if I [size=3]search for “ba.”[/size] How would I change the code so that any data field is highlighted if the search string exists anywhere in the text for the data field?
Also, I figured out how to stop the form fields from being yellow if they and the search field are empty/NULL, but I did this part in another file (as an IF statement) and can’t seem to get it to work in [font=times new roman]the other file. How would I make it do the highlighting if and only if there is a search string in the search field (i. e. only highlighting when the search field is not NULL/empty).