Here's a littl something built specifically to do what you are looking
for.

save this is a js file

// JavaScript Document
function xmlhttpPost(strURL,formElementID,destinationID,selectName) {
     var xmlHttpReq = false;
     var self = this;
        var preloadVal=""
        // next 4 lines allow you to preload the select box with a selection
        var doPreload=false;
        if(arguments.length >= 5) {
                doPreload=arguments[4];
                preloadVal=arguments[5];
        }
     // Mozilla/Safari
        if (window.XMLHttpRequest) {
          self.xmlHttpReq = new XMLHttpRequest();
        }
     // IE
        else if (window.ActiveXObject) {
          self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
        }
          self.xmlHttpReq.open('POST', strURL, true);
          self.xmlHttpReq.setRequestHeader('Content-Type',
'application/x-www-form-urlencoded');
          self.xmlHttpReq.onreadystatechange = function() {
            if (self.xmlHttpReq.readyState == 4) {
               updatepage(self.xmlHttpReq.responseText,destinationID);
            }
        }
          if(doPreload) {
                        
self.xmlHttpReq.send(getPreloadString(selectName,preloadVal));
                }
                else {
                        
self.xmlHttpReq.send(getquerystring(formElementID,selectName));
                }
   }

function getquerystring(formElementID,selectName) {
     var form     = document.getElementById(formElementID).value;
     qstr = 'w=' + escape(form)+'&sf='+selectName;  // NOTE: no '?'
before querystring
     return qstr;
}
function getPreloadString(selectName,val) {
        qstr = 'w=' + val+'&sf='+selectName;  // NOTE: no '?' before
querystring
     return qstr;
}
//sends the new data to the page
function updatepage(str,destinationID){
        if(str.length > 10) {
      if(navigator.appName == "Microsoft Internet Explorer"){
       var obj=document.all[destinationID].innerHTML = str;
      }else{
       document.getElementById(destinationID).innerHTML = str;
      }
        //document.getElementById(destinationID).innerHTML = str;
        }
}

On your calling page you need the text box you type in and a related
select.  Put the select in a div with it's own ID; something like this

<div class="frmrow"><label>Person 1</label><input type="text"
id="keydcowner" name="keydcowner" size="10" onkeyup='xmlhttpPost("../
js/getUsers.cfm","keydcowner","showdcowner","dcowner")' /><span
id="showdcowner"><select name="dcowner" id="dcowner"><option
value="">Begin typing last name in box to left</option></select></
span></div>

In the div block above
strURL = the page that does the query and returns a complete select
box
formElementID = the text box users will type in
destinationID = the div where the new select box is returned
selectName = the name of the select you are returning

The getUsers.cfm page is a very simple page.  Just a query and a
select box with a cfoutput to create option lists.

Couple of things to remember.
Use VALID XHTML (<option value="" selected="selected">text</option>)
Turn off debug.
either use a cfabort in the query page after the select is created or
don't use an onrequestend.cfm

This is pretty simple, very light weight and provides the ability for
you to use it multiple times on the same page.  Only drawback is that
is VERY specific in what it does.

HTH,

M

On Jul 10, 2:59 pm, Eddie Pequeno <[EMAIL PROTECTED]> wrote:
> Does anybody know any sites with good refrences to AJAX?
>  
> There is some built in Ajax functionallity with CF8 but I don't know if it's 
> enough to do what I need. The cfajaxproxy looks quite promising though.
>  
> Here's what I'm trying to do:
>  
> I'm putting a lot of Company names in a drop down. The list will be enormous 
> so instead of having all the names, I will put only the letters A - Z . When 
> a user selects the B for example, a box with the list of companies will pop 
> open and be filterd to show only the companies that begin with the letter 
> "B". Then the user can select form the filterd list.
>  
> I think I recall that Ken showed us something like this at one of our 
> BeerFUGs a while back.
>  
> -Eddie
>  
>  
>  
>  
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the "Houston ColdFusion 
Users' Group" discussion list.
To unsubscribe, send email to [EMAIL PROTECTED]
For more options, visit http://groups.google.com/group/houcfug?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to