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

Dynamiclly changing the scriptQueryAppend for AutoComplete

Expand Messages
  • listeninglibrary
    I would like to change the scriptQueryAppend of the second inputbox depending on what the first input box is currently displaying. I am assuming it can be done
    Message 1 of 1 , May 11 9:35 AM
    • 0 Attachment
      I would like to change the scriptQueryAppend of the second inputbox
      depending on what the first input box is currently displaying. I am
      assuming it can be done using some kind of CustomEvent handler but I'm
      not quite sure how.

      Here is the sample code:

      <div id="ysearchautocomplete1"
      style="margin-bottom:0px;margin-top:0px;">
      <input id="ysearchinput1" name="SOFTWARENAME"
      style="font-family:arial;font-size:12px;width:400px;margin-bottom:0px;margin-top:0px;">
      <div id="ysearchcontainer1"
      style="margin-bottom:0px;margin-top:0px;width:400px;"></div>
      </div>

      <div id="ysearchautocomplete2" style="margin-bottom:0px;margin-top:0px;">
      <input id="ysearchinput2" name="SOFTWAREVERSION"
      style="font-family:arial;font-size:12px;width:400px;margin-bottom:0px;margin-top:0px;">
      <div id="ysearchcontainer2"
      style="margin-bottom:0px;margin-top:0px;width:400px;"></div>
      </div>



      oACDS1 = new YAHOO.widget.DS_XHR("getSoftware.asp", ["\n", "\t"]);
      oACDS1.responseType = YAHOO.widget.DS_XHR.TYPE_FLAT;
      oACDS1.maxCacheEntries = 60;
      oACDS1.queryMatchSubset = true;

      oACDS2 = new YAHOO.widget.DS_XHR("getSoftwareVersion.asp", ["\n", "\t"]);
      oACDS2.responseType = YAHOO.widget.DS_XHR.TYPE_FLAT;
      oACDS2.maxCacheEntries = 60;
      oACDS2.queryMatchSubset = true;

      oACDS2.scriptQueryAppend =
      "SOFTWARETYPE="+document.getElementById('ysearchinput1').value;

      var myInput1 = document.getElementById('ysearchinput1');
      var myContainer1 = document.getElementById('ysearchcontainer1');
      oAutoComp1 = new
      YAHOO.widget.AutoComplete(myInput1,myContainer1,oACDS1);
      oAutoComp1.delimChar = "";
      oAutoComp1.queryDelay = 0;
      oAutoComp1.formatResult = function(oResultItem, sQuery) {

      var sKey = oResultItem[0];
      var nQuantity = oResultItem[1];
      var sKeyQuery = sKey.substr(0, sQuery.length);
      var sKeyRemainder = sKey.substr(sQuery.length);
      var aMarkup = ["<div id='ysearchresult'><div
      class='ysearchquery'>",nQuantity,"</div><span
      style='font-weight:bold'>",sKeyQuery,"</span>",sKeyRemainder,"</div>"];
      return (aMarkup.join(""));
      };

      var myInput2 = document.getElementById('ysearchinput2');
      var myContainer2 = document.getElementById('ysearchcontainer2');
      oAutoComp2 = new
      YAHOO.widget.AutoComplete(myInput2,myContainer2,oACDS2);
      oAutoComp2.delimChar = "";
      oAutoComp2.queryDelay = 0;
      oAutoComp2.formatResult = function(oResultItem, sQuery) {

      oACDS2.scriptQueryAppend =
      "SOFTWARETYPE="+document.getElementById('ysearchinput1').value;

      var sKey = oResultItem[0];
      var nQuantity = oResultItem[1];
      var sKeyQuery = sKey.substr(0, sQuery.length);
      var sKeyRemainder = sKey.substr(sQuery.length);
      var aMarkup = ["<div id='ysearchresult'><div
      class='ysearchquery'>",nQuantity,"</div><span
      style='font-weight:bold'>",sKeyQuery,"</span>",sKeyRemainder,"</div>"];
      return (aMarkup.join(""));
      };
    Your message has been successfully submitted and would be delivered to recipients shortly.