var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: Insensitive case string replace
I have one function on my web where I use one string to search some datafields. After finding and listing this articles, I would like to termin by which user has searched to be marked.
Something like that:
This works great but only if characters case matched, so how to make replace insensitive to upper and lower characters.
You can use one of the following functions.
LCase(string) returns a string that has been converted to lowercase.
UCase(string) returns a string that has been converted to uppercase.
what you need to do is use the lcase and ucase functions as gyuan meantioned but you need to use them to locate the string and not replace it... once you have located the string then you can wrap it in bold tags,... some thing like.....
You should of course make this a lot prettier and robust and make sure that the start and end locations are right (they might be out by one) but in priniciple it is what you need to do
function highlight(yourString, strToHighlight)
tmpString = LCase(yourString)
startLoc = instr(1, lcase(yourString), strToHighlight)
endLoc - startLoc + len(strToHighlight)
resultString = left(yourString, startLoc)
resultString = resultString & "<b>" & strToHighlight & "</b>"
resultString = resultString & mid(yourString, endLoc)
highlight = resultString
Thanks a lot, my code looks like that:
myString = rsArtikli.Fields.Item("Naziv").Value
startLoc = instr(1, lcase(myString), Pojam)
resultString = left(myString, startLoc-1) & "<font color=""red"">"
resultString = resultString & mid(myString,startLoc,len(pojam)) & "</font>"
resultString = resultString & mid(myString,startLoc+len(pojam))
If the phrase appears only once that will work great,.. what is it appears twice, do you want both instances highlighted??
Setting it up in a function would be a lot useful later I think...
I didn't know how to use function
, I will check it on web.
see how my code is written as a function above??
You can call it by simply going...
Just have the function at the end of all your asp code.