View Full Version : Senocular XML search tutorial (search query case sensitive)
Inertia
December 3rd, 2004, 11:07 PM
Hi
I've just tried senocular's xml tutorials.
http://www.kirupa.com/web/xml/examples/searchbestof.htm
The search query seems case sensitive. How to make it accept upper and lower case characters. Actually i'm trying to make a search by myself by using the same code. :eye:
lostinbeta
December 3rd, 2004, 11:17 PM
The easiest method would be to convert the search string and the string to search to either all uppercase or all lowercase.
You can use the String.toUpperCase() and String.toLowerCase() to achieve this.
This conversion of course only has to be done in the query for comparison.
Inertia
December 4th, 2004, 12:13 AM
The easiest method would be to convert the search string and the string to search to either all uppercase or all lowercase.
You can use the String.toUpperCase() and String.toLowerCase() to achieve this.
This conversion of course only has to be done in the query for comparison.Thank you very much. But where I've add that method.. It seems totally confusing. I think this portion to be modified. Could u pls suggest that. :puzzled:
search_fields.search_btn.onRelease = function(){
if (search_fields.query_txt.text.length < 3){
results_txt.text = "Please use a search term with 3 or more characters.";
return (0);
}
var searchElements = ElementsToSearch();
var nodesWithQuery = SearchXML(
posts_xml.firstChild.childNodes,
search_fields.query_txt.text,
searchElements
);
if (nodesWithQuery.length){
DisplayNodes(
nodesWithQuery,
results_txt
);
}else{
results_txt.text = "No results for "+search_fields.query_txt.text+".";
return (0);
}
HighlightOccurences(
search_fields.query_txt.text,
results_txt,
search_highlight
);
scrollbar.setScroll(0);
}
lostinbeta
December 4th, 2004, 12:37 AM
Well, I can tell that isn't the full code, but I can give you a point. It would seem like the 'search_fields.query_txt.text' in the SearchXML (in the var nodesWithQuery) would need to be toUpperCased, and you don't have the SearchXML() function displayed, but it would seem something in there would need to be toUpperCased as well... and that would be whatever argument accepts the post_xml.firstChild.childNodes value.
Since childNodes is an array you can't toUpperCase that in the function call like you can with the textbox text. So I'm assuming the SearchXML() function contains a for loop to loop through the childNodes array, in which you would have to use a toUpperCase() to the value of each child node to compare.
If that makes any sense.
Inertia
December 4th, 2004, 02:50 AM
I've made the corrections u suggested but it seems unreachable. This is the url of the original file
http://www.kirupa.com/web/xml/examples/searchbestof.htm
I hope u've already seem this but just for u r attention. I'm in trouble :h:
Inertia
December 4th, 2004, 03:18 AM
Hi,
The search is ok.. one of my friend helped me to solve this problem. the code is something like this.. two strings converted to upperCase ();
if (currNode.firstChild.nodeValue.toUpperCase().conta ins(query.toUpperCase())){
:D
lostinbeta
December 4th, 2004, 11:01 AM
Which is basically what I said to do ;) Just not having the whole code I had to take a wild guess to which strings.
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.