Loading ...
Sorry, an error occurred while loading the content.

Autocomplete showing only one result: XML

Expand Messages
  • tomashelikar
    Hi, I ve spent last several days to get the autocomplete working right, however, with no luck. I am using the XML version of the data source object. The
    Message 1 of 1 , Apr 3, 2007
    • 0 Attachment
      Hi,
      I've spent last several days to get the autocomplete working right,
      however, with no luck. I am using the XML version of the data source
      object. The problem is that autocomplete returns only the first
      element form the xml file. You can see its behaviour at:
      www.imouse.gsbrno.cz/autocomplete.php

      Thanks!
      here's the code:

      <html>
      <head>
      <title>Example: AutoComplete - Basic XML Data (YUI Library)</title>
      <style type="text/css">
      #ysearchmod {position:relative;padding:1em;}
      #ysearchautocomplete {position:relative;margin:1em;width:40%;}/*
      set width of widget here*/
      #ysearchinput {position:absolute;width:100%;height:1.4em;}
      #ysearchcontainer {position:absolute;top:1.7em;width:100%;}
      #ysearchcontainer .yui-ac-content
      {position:absolute;width:100%;border:1px solid
      #404040;background:#fff;overflow:hidden;z-index:9050;}
      #ysearchcontainer .yui-ac-shadow
      {position:absolute;margin:.3em;width:100%;background:#a0a0a0;z-index:9049;}
      #ysearchcontainer ul {padding:5px 0;width:100%;}
      #ysearchcontainer li {padding:0
      5px;cursor:default;white-space:nowrap;}
      #ysearchcontainer li.yui-ac-highlight {background:#ff0;}
      </style>
      </head>
      <body>
      <div id="bd">
      <!-- AutoComplete begins -->
      <div id="ysearchmod">

      <form onsubmit="return false">
      <h2 onclick="alert(oAutoComp.toString());">Yahoo! Search</h2>
      <div id="ysearchautocomplete">
      <input id="ysearchinput">
      <div id="ysearchcontainer"></div>
      </div>
      </form>
      </div>

      </div>
      <!-- AutoComplete ends -->
      <!-- form onsubmit="return false">
      <p>Search autocomplete:
      <div id="propertysearch">
      <input autocomplete="off" id="searchinput" />
      <div id="searchresults">
       
      </div>
      </div>
      </form -->
      </body>
      </html>
      <!-- Dependencies -->
      <script type="text/javascript"
      src="http://yui.yahooapis.com/2.2.0/build/yahoo-dom-event/yahoo-dom-event.js"></\
      script>


      <!-- OPTIONAL: Connection (required only if using XHR DataSource) -->
      <script type="text/javascript"
      src="http://yui.yahooapis.com/2.2.0/build/connection/connection-min.js"></script\
      >


      <!-- OPTIONAL: Animation (required only if enabling animation) -->
      <script type="text/javascript"
      src="http://yui.yahooapis.com/2.2.0/build/animation/animation-min.js"></script>


      <!-- OPTIONAL: External JSON parser from http://www.json.org/
      (enables JSON validation) -->
      <script type="text/javascript"
      src="http://www.json.org/json.js"></script>

      <!-- Source file -->
      <script type="text/javascript"
      src="http://yui.yahooapis.com/2.2.0/build/autocomplete/autocomplete-min.js"></sc\
      ript>

      <script type="text/javascript">
      // Instantiate an XHR DataSource and define schema as an
      array:
      //
      ["Multi-depth.object.notation.to.find.a.single.result.item",
      // "Query Key",
      // "Additional Param Name 1",
      // ...
      // "Additional Param Name n"]
      oACDS = new YAHOO.widget.DS_XHR("./example.xml",
      ["person", "name"]);
      //alert(oACDS.toString());
      oACDS.responseType = YAHOO.widget.DS_XHR.TYPE_XML;
      oACDS.queryMatchContains = true;
      /*oACDS.scriptQueryAppend = "results=100"; // Needed for YWS*/

      // Instantiate AutoComplete
      oAutoComp = new
      YAHOO.widget.AutoComplete("ysearchinput","ysearchcontainer", oACDS);
      </script>

      Any help/suggestion are greatly appreciated.

      Thanks a lot,
      Tom
    Your message has been successfully submitted and would be delivered to recipients shortly.