I need to parse xml and display as autocomplete in the text field in phone gap using jquery -
<!doctype html> <html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1"> <link href="jquery-mobile/styles/jquery.mobile-1.3.1.min.css" rel="stylesheet" /> <link href="styles/main.css" rel="stylesheet" /> <script src="cordova.js" type="text/javascript"></script> <script src="jquery-mobile/js/jquery-1.9.1.min.js" type="text/javascript"></script> <script src="jquery-mobile/js/jquery.mobile-1.3.1.min.js" type="text/javascript"></script> <script> function loadxmldoc(url) { window.plugins.orientation.lock("portrait") var xmlhttp; var txt,x,xx,i; if (window.xmlhttprequest) {// code ie7+, firefox, chrome, opera, safari xmlhttp=new xmlhttprequest(); } else {// code ie6, ie5 xmlhttp=new activexobject("microsoft.xmlhttp"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readystate==4 && xmlhttp.status==200) { txt="<table border='1'><tr><th>company</th><th>country</th><th>city</th></tr>"; x=xmlhttp.responsexml.documentelement.getelementsbytagname("cd"); (i=0;i<x.length;i++) { txt=txt + " <tr>"; xx=x[i].getelementsbytagname("company"); { try { txt=txt + "<td>" + xx[0].firstchild.nodevalue + "</td>"; } catch (er) { txt=txt + "<td> </td>"; } } xx=x[i].getelementsbytagname("country"); { try { txt=txt + "<td>" + xx[0].firstchild.nodevalue + "</td>"; } catch (er) { txt=txt + "<td> </td>"; } } xx=x[i].getelementsbytagname("title"); { try { txt=txt + "<td>" + xx[0].firstchild.nodevalue + "</td>"; } catch (er) { txt=txt + "<td> </td>"; } } txt=txt + "</tr>"; } txt=txt + "</table>"; document.getelementbyid('txtcdinfo').innerhtml=txt; } } xmlhttp.open("get",url,true); xmlhttp.send(); } </script> </head> <body> <!--home--> <div id="home" data-role="page" data-mini="true"> <div data-role="header" data-position="fixed" data-tap-toggle="false"> <h1>welcome</h1> </div> <div class="info-wrapper"> <div class="info-wrapper-left"> <img class="ice-logo"/> </div> <div class="clear"></div> </div> <div data-role="content"> <ul data-role="listview" id="a" data-inset="true" data-theme="d"> <li> <a href="#home1" data-transition="slide"> services </a> </li> </ul> <ul data-role="listview" id="a" data-inset="true" data-theme="d"> <li> <a href="#home2" data-transition="slide">port</a> </li> </ul> <ul data-role="listview" id="a" data-inset="true" data-theme="d"> <li> <a href="#home3" data-transition="slide">teasr</a> </li> </ul> <ul data-role="listview" id="c" data-inset="true" data-theme="d"> <li> <a href="#home4" data-transition="slide">cvservices</a> </li> </ul> </div> </div> <!--home end--> <!--programprogress page--> <div id="programprogress" data-role="page" data-add-back-btn="true"> <div data-role="header" data-position="fixed" data-tap-toggle="false"> <h1>progress</h1> </div> <div data-role="content"> <ul data-role="listview" id="ul3" data-inset="true" data-theme="d"> <li>coming soon!</li> </ul> </div> </div> <div id="**search**" data-role="page" data-add-back-btn="true"> <div data-role="header" data-position="fixed"> <h1>service company search</h1> </div> <div data-role="content"> <form id="search" action="#samp"> <div data-role="fieldcontain"> <label for="company">company</label> <input type="text" id="company" name="company" class="required company" /> </div> <div data-role="fieldcontain"> <label for="country">country</label> <input type="text" id="country" name="country" class="required" /> </div> <div data-role="fieldcontain"> <label for="city">city</label> <input type="text" id="city" name="city" class="required" /> </div> <div class="ui-body ui-body-b"> <fieldset class="ui-grid-a"> <div class="ui-block-a"> <button id="btncancel" data-theme="d">cancel</button> </div> <div class="ui-block-b"> <a href="#samp" data-transition="slide"><button onclick="loadxmldoc('cd_catalog.xml')">search</button></a> </div> </fieldset> </div> </form> </div> </div> <!--service company search end--> <div id="samp" data-role="page" data-add-back-btn="true"> <div data-role="header" data-position="fixed"> <h1>service company search</h1> </div> <div id="txtcdinfo" data-role="content"> </div> </div> </body> </html>
this phonegap application here need use autocomplete textbox xml file using javascript or jquery.
- for instance take country field when start typing country should auto complete list in xml filtering particular letter typed.
this urgent requirement please me. full me continue task
you can use jquery auto complete widget. refer below links further readings. let me know if find problems use this.
Comments
Post a Comment