Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
New Contributor
Posts: 2
Registered: ‎07-05-2011
My Device: Bold
My Carrier: Developer

how to do Javascript/XML based search using XMLHTTP RSS

Hai friend

i tryed this please check this code and resolve my bugs

<html>
<script language="javascript" type="text/javascript">
        if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp = new XMLHttpRequest();
    }
    else {// code for IE6, IE5
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.open("GET", "index.xml", false);
    xmlhttp.send();
    xmlDoc = xmlhttp.responseXML;
    var x;
      var y = 0;
     x = xmlDoc.getElementsByTagName("Search");      
    
        function searchIndex()
        {             
            // get the search term from a form field with id 'searchme'
            results = new Array;
            var searchterm = document.getElementById("searchme").value;
            
 
            if (searchterm == null || searchterm == "")
            {
                alert("Enter at least three characters");
                return false;
            }
 
            if (isNaN(searchterm))
             {
 
                    alert("Enter numberic value only");
                    false;
 
             }
 
                var istrlen = searchterm.length;                
                var tempname;
 
                if (istrlen == 1) {
                    
                    tempname =  searchterm;
                }
 
                if (istrlen == 2) {
                    
                    tempname = searchterm;
                }
 
                if (istrlen == 3) {
                    
                    tempname =  searchterm;
                }
 
              
            for (i = 0; i < x.length; i++)
            {    
                    // see if the XML entry matches the search term,
                    // and (if so) store it in an array
                var name = x[i].childNodes[0].firstChild.nodeValue;
                                
 
                    //var lnkname = x[i].childNodes[0].firstChild.nodeValue;
                    //alert(lnkname);                    
                    //var exp = new RegExp(searchterm, "i");
                var res = name.search(tempname);
            
                    if (res >= 0)
                    {
                        y = y + 1;   
                            
                        results.push(name);            
                        
                        document.write(name + "<br />");
 
 
                     }
                }
            }  
             
        
 
        function test(name, lnkname)
        {
           
            document.write('<table border="0" style="width:100%">');
            for (var i = 0; i < x.length; i++)
           {       
        //var sear=x[i].childNodes[0].firstChild.nodeValue //+ x[i].childNodes[0].firstChild.nodeValue;    
            document.write("<tr onclick='displayInfo(" + i + ")'>");            
            document.write('<td>' + x[i].childNodes[0].firstChild.nodeValue + '</td>');
            document.write('</tr>');
            }
        //document.getElementById("show").innerHTML = sear;
            document.write('<table>');
            document.close();
        }    
    
 
        //
    </script>
 
</head>
<body>
    <input id="searchme" type="text" size="20">&nbsp;&nbsp;<input type="button" value="Search" onclick="searchIndex(); return false;" />
 
 
<div id="show"></div>
</body>
</html>