RE: CF, Ajax and Autocomplete Problems
Hi All Ok seem to be getting somewhere now, or at least I'm getting errors back, the page is internal and not on the web. On the search form page I am getting a JavaScript error 'bsn is undefined'? The original code was for php which I think works superb at http://www.brandspankingnew.net/archive/2007/02/ajax_auto_suggest_v2.htm l and I can't use the new autosuggest feature in CF 8 as I am on CF 7. Search form code - form method=get action= label for=testinput_xmlPerson/label input type=text id=testinput_xml name=surname value= style=width:300px / br /br /input type=submit value=submit / /form script type=text/javascript var options_xml = { script: function (input) { return include.cfm+input++document.getElementsByTagname('rs')[0].getAttribu te('info').value; }, varname:input }; var as_xml = new bsn.AutoSuggest('testinput_xml', options_xml); /script -- Also when trying the include.cfm page on its own independent to the search form to test it out I get the error The XML page cannot be displayed Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later. Incorrect syntax was used in a comment. Error processing resource Include.cfm page is below --- cfsilent cfsetting enablecfoutputonly=yes cfquery name=getNames datasource=dsn SELECT surname FROM tablename WHERE surname LIKE '%#url.as#%' ORDER by surname ASC /cfquery cfcontent type=text/xml; charset=UTF-8 reset=yes/cfoutput#theXML#/cfoutput cfloop from=1 to=#getNames.recordcount# index=ctr cfoutput !--- add the XML config entry --- rs id= info=#getNames.surname[ctr]##getNames.surname[ctr]#/rs /cfoutput /cfloop cfoutput /results /cfoutput cfoutput#theXML#/cfoutput /cfsilent ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:312655 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
RE: CF, Ajax and Autocomplete Problems
I think your trick will be to first get your CF XML output to match the XML output from PHP. Once you have done that, your problems should be solved. You should be able to view XML in a browser. Firefox works great when viewing XML. IE not so great, sometimes. Mike -Original Message- From: Ian Vaughan [mailto:[EMAIL PROTECTED] Sent: Wednesday, September 17, 2008 5:46 AM To: CF-Talk Subject: RE: CF, Ajax and Autocomplete Problems Hi All Ok seem to be getting somewhere now, or at least I'm getting errors back, the page is internal and not on the web. ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:312666 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: CF, Ajax and Autocomplete Problems
Hi I'm trying to incorporate an Ajax autosuggest feature into a Coldfusion search page I have. The example I have found is for PHP, and I'm trying to get this to work with Coldfusion The original autocomplete script and working example can be found athttp://www.brandspankingnew.net/archive/2007/02/ajax_auto_suggest_v2.h tml When trying the search form, I am not getting any errors, but the autocomplete box is not appearing. Any ideas on what is causing the autocomplete not working correctly? Ian --- SEARCH FORM--- div form method=get action= label for=testinput_xmlPerson/label input type=text id=testinput_xml name=surname value= style=width:300px / br /br / input type=submit value=submit / /form /div script type=text/javascript var options_xml = { script: function (input) { return include.cfm+input++document.getElementsByTagname('rs')[0].getAttribu te('info').value; }, varname:input }; var as_xml = new bsn.AutoSuggest('testinput_xml', options_xml); /script - INCLUDE.CFM - cfsetting enablecfoutputonly=yes cfquery name=getNames datasource=dsn SELECT surname FROM ourtablename WHERE surname LIKE cfqueryparam cfsqltype=cf_sql_varchar value=#form.surname# ORDER by surname ASC /cfquery cfsavecontent variable=theXML cfoutput?xml version=1.0 encoding=UTF-8?results/cfoutput cfloop from=1 to=#getNames.recordcount# index=ctr cfoutput !--- add the XML config entry --- rs id= info=#getNames.surname[ctr]##getNames.surname[ctr]#/rs /cfoutput /cfloop cfoutput /results /cfoutput /cfsavecontent cfoutput#theXML#/cfoutput -- ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:312565 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: CF, Ajax and Autocomplete Problems
Perhaps the js code is wanting the response format to have an xml type header and/or dislikes whitespace at the top of the output. Try this: cfcontent type=text/xml; charset=UTF-8 reset=yes /cfoutput#theXML#/cfoutput You may also want to take a look at cfinput autosuggest=... and http://betterautosuggest.riaforge.org for native ColdFusion/YUI solutions if things get messy with your current solution. HTH Dominic 2008/9/16 Ian Vaughan [EMAIL PROTECTED]: Hi I'm trying to incorporate an Ajax autosuggest feature into a Coldfusion search page I have. The example I have found is for PHP, and I'm trying to get this to work with Coldfusion The original autocomplete script and working example can be found athttp://www.brandspankingnew.net/archive/2007/02/ajax_auto_suggest_v2.h tml When trying the search form, I am not getting any errors, but the autocomplete box is not appearing. Any ideas on what is causing the autocomplete not working correctly? Ian --- SEARCH FORM--- div form method=get action= label for=testinput_xmlPerson/label input type=text id=testinput_xml name=surname value= style=width:300px / br /br / input type=submit value=submit / /form /div script type=text/javascript var options_xml = { script: function (input) { return include.cfm+input++document.getElementsByTagname('rs')[0].getAttribu te('info').value; }, varname:input }; var as_xml = new bsn.AutoSuggest('testinput_xml', options_xml); /script - INCLUDE.CFM - cfsetting enablecfoutputonly=yes cfquery name=getNames datasource=dsn SELECT surname FROM ourtablename WHERE surname LIKE cfqueryparam cfsqltype=cf_sql_varchar value=#form.surname# ORDER by surname ASC /cfquery cfsavecontent variable=theXML cfoutput?xml version=1.0 encoding=UTF-8?results/cfoutput cfloop from=1 to=#getNames.recordcount# index=ctr cfoutput !--- add the XML config entry --- rs id= info=#getNames.surname[ctr]##getNames.surname[ctr]#/rs /cfoutput /cfloop cfoutput /results /cfoutput /cfsavecontent cfoutput#theXML#/cfoutput -- ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:312566 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: CF, Ajax and Autocomplete Problems
Hi Dominic Just tried what you suggested, but its still the same? This is the original php script, perhaps Coldfusion can't offer the same functionality as PHP, that's why there are problems implementing it in CF? --- ?php //arrays are hard coded, but these could be populated from a database $aUsers = array( Ädams, Egbert, Altman, Alisha, Archibald, Janna, ); $aInfo = array( Bedfordshire, Buckinghamshire, Cambridgeshire, Cheshire, Cornwall, Cumbria, Derbyshire, ); $input = strtolower( $_GET['input'] ); $len = strlen($input); $aResults = array(); if ($len) { for ($i=0;$icount($aUsers);$i++) { // had to use utf_decode, here // not necessary if the results are coming from mysql // if (strtolower(substr(utf8_decode($aUsers[$i]),0,$len)) == $input) $aResults[] = array( id=($i+1) ,value=htmlspecialchars($aUsers[$i]), info=htmlspecialchars($aInfo[$i]) ); //if (stripos(utf8_decode($aUsers[$i]), $input) !== false) // $aResults[] = array( id=($i+1) ,value=htmlspecialchars($aUsers[$i]), info=htmlspecialchars($aInfo[$i]) ); } } header (Expires: Mon, 26 Jul 1997 05:00:00 GMT); // Date in the past header (Last-Modified: . gmdate(D, d M Y H:i:s) . GMT); // always modified header (Cache-Control: no-cache, must-revalidate); // HTTP/1.1 header (Pragma: no-cache); // HTTP/1.0 { header(Content-Type: text/xml); echo ?xml version=\1.0\ encoding=\utf-8\ ?results; for ($i=0;$icount($aResults);$i++) { echo rs id=\.$aResults[$i]['id'].\ info=\.$aResults[$i]['info'].\.$aResults[$i]['value']./rs; } echo /results; } ? ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:312580 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: CF, Ajax and Autocomplete Problems
Ian Vaughan wrote: Just tried what you suggested, but its still the same? Do you mean that as a question Is it still the same? or do you mean that as a statement It is still the same.? This is the original php script, perhaps Coldfusion can't offer the same functionality as PHP, that's why there are problems implementing it in CF? Funny. I wonder if you believe that or if you are just trolling. :) What are you trying to do here? I'm sure CF can handle it (in less lines even). ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:312581 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: CF, Ajax and Autocomplete Problems
Sorry man. Just got a bit annoyed that someone came onto a CF list and starting saying PHP can do something that CF can't (which is a lie). http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=Tags_i_07.html Read that over and try it out. Pay special attention to autosuggest. Your code there may be shortened to 1 line. :) Phillip M. Vector wrote: Ian Vaughan wrote: Just tried what you suggested, but its still the same? Do you mean that as a question Is it still the same? or do you mean that as a statement It is still the same.? This is the original php script, perhaps Coldfusion can't offer the same functionality as PHP, that's why there are problems implementing it in CF? Funny. I wonder if you believe that or if you are just trolling. :) What are you trying to do here? I'm sure CF can handle it (in less lines even). ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:312583 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: CF, Ajax and Autocomplete Problems
My suggestion would be to create a .cfm page with no dynamic code. Have it ONLY output pure XML. Heck, even take the XML generated by the PHP page and paste it into the .cfm page. As with the original poster, however, make sure there is no white space above the first XML tag. Also, us the CFCONTENT tag to ensure that you are sending it as an XML MIME type. AJAX does not care what application server sends the XML. It only cares that it is valid XML. Mike -Original Message- From: Ian Vaughan [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 16, 2008 8:53 AM To: CF-Talk Subject: RE: CF, Ajax and Autocomplete Problems Hi Dominic Just tried what you suggested, but its still the same? This is the original php script, perhaps Coldfusion can't offer the same functionality as PHP, that's why there are problems implementing it in CF? ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:312584 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
RE: CF, Ajax and Autocomplete Problems
Hi Mike I have surrounded it with a cfsilent tag to remove the white space, and its still the same, no errors but no results appear? And I'm using cfcontent as below. cfsilent /cfsilentcfsetting enablecfoutputonly=yes cfquery name=getNames datasource=dsn SELECT surname FROM tablename WHERE surname LIKE cfqueryparam cfsqltype=cf_sql_varchar value=#form.surname# ORDER by surname ASC /cfquery cfcontent type=text/xml; charset=UTF-8 reset=yes/cfoutput#theXML#/cfoutput cfloop from=1 to=#getNames.recordcount# index=ctr cfoutput !--- add the XML config entry --- rs id= info=#getNames.surname[ctr]##getNames.surname[ctr]#/rs /cfoutput /cfloop cfoutput /results /cfoutput /cfsavecontent cfoutput#theXML#/cfoutput /cfsilent -Original Message- From: Dawson, Michael [mailto:[EMAIL PROTECTED] Sent: 16 September 2008 15:00 To: CF-Talk Subject: RE: CF, Ajax and Autocomplete Problems My suggestion would be to create a .cfm page with no dynamic code. Have it ONLY output pure XML. Heck, even take the XML generated by the PHP page and paste it into the .cfm page. As with the original poster, however, make sure there is no white space above the first XML tag. Also, us the CFCONTENT tag to ensure that you are sending it as an XML MIME type. AJAX does not care what application server sends the XML. It only cares that it is valid XML. Mike -Original Message- From: Ian Vaughan [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 16, 2008 8:53 AM To: CF-Talk Subject: RE: CF, Ajax and Autocomplete Problems Hi Dominic Just tried what you suggested, but its still the same? This is the original php script, perhaps Coldfusion can't offer the same functionality as PHP, that's why there are problems implementing it in CF? ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:312586 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: CF, Ajax and Autocomplete Problems
Can you provide us with the link to this page? Mike -Original Message- From: Ian Vaughan [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 16, 2008 9:28 AM To: CF-Talk Subject: RE: CF, Ajax and Autocomplete Problems Hi Mike I have surrounded it with a cfsilent tag to remove the white space, and its still the same, no errors but no results appear? And I'm using cfcontent as below. ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:312593 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: CF, Ajax and Autocomplete Problems
Also, I see an ending /results tag, but no beginning results tag. Mike -Original Message- From: Ian Vaughan [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 16, 2008 9:28 AM To: CF-Talk Subject: RE: CF, Ajax and Autocomplete Problems Hi Mike I have surrounded it with a cfsilent tag to remove the white space, and its still the same, no errors but no results appear? And I'm using cfcontent as below. cfsilent /cfsilentcfsetting enablecfoutputonly=yes cfquery name=getNames datasource=dsn SELECT surname FROM tablename WHERE surname LIKE cfqueryparam cfsqltype=cf_sql_varchar value=#form.surname# ORDER by surname ASC /cfquery cfcontent type=text/xml; charset=UTF-8 reset=yes/cfoutput#theXML#/cfoutput cfloop from=1 to=#getNames.recordcount# index=ctr cfoutput !--- add the XML config entry --- rs id= info=#getNames.surname[ctr]##getNames.surname[ctr]#/rs /cfoutput /cfloop cfoutput /results /cfoutput /cfsavecontent cfoutput#theXML#/cfoutput /cfsilent ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:312594 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: CF, Ajax and Autocomplete Problems
That code should through errors or output invalid xml, unless what you have posted is not the complete code. Visit the page in your browser and you should see some verbose errors from either coldfusion or your browser's xml parser. Dominic 2008/9/16 Ian Vaughan [EMAIL PROTECTED]: Hi Mike I have surrounded it with a cfsilent tag to remove the white space, and its still the same, no errors but no results appear? And I'm using cfcontent as below. cfsilent /cfsilentcfsetting enablecfoutputonly=yes cfquery name=getNames datasource=dsn SELECT surname FROM tablename WHERE surname LIKE cfqueryparam cfsqltype=cf_sql_varchar value=#form.surname# ORDER by surname ASC /cfquery cfcontent type=text/xml; charset=UTF-8 reset=yes/cfoutput#theXML#/cfoutput cfloop from=1 to=#getNames.recordcount# index=ctr cfoutput !--- add the XML config entry --- rs id= info=#getNames.surname[ctr]##getNames.surname[ctr]#/rs /cfoutput /cfloop cfoutput /results /cfoutput /cfsavecontent cfoutput#theXML#/cfoutput /cfsilent ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:312613 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: CF, Ajax and Autocomplete Problems
Hi, I may also be missing something here, but why are you opening a cfsilent and then closing it straight away? cfsilent /cfsilentcfsetting enablecfoutputonly=yes. The very last line of code has a closing cfsilent with no opening tag. Cheers Mark ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:312640 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
RE: CF, Ajax and Autocomplete Problems
I'm not sure if the mailing list cut off some code, but your SELECT statement is missing your variable after the LIKE keyword. mike -Original Message- From: Ian Vaughan [mailto:[EMAIL PROTECTED] Sent: Friday, September 12, 2008 9:34 AM To: CF-Talk Subject: CF, Ajax and Autocomplete Problems Hi I have been trying to get script.aculo.us autocomplete code to work with Coldfusion, with no avail, and would appreciate any advice / guidance on what I am doing wrong please. When typing in the search box no suggestions appear? Its based on code from http://www.petefreitag.com/item/605.cfm Here is my code !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN http://www.w3.org/TR/html4/loose.dtd; html head meta http-equiv=Content-Type content=text/html; charset=iso-8859-1 titleUntitled Document/title script src=/js/prototype.js type=text/javascript/script script src=/js/scriptaculous.js type=text/javascript/script style ...selected { background-color: #f1f1f1; } #suggestionBox { display:none; border: 1px solid silver; } /style /head body form action=search.cfm input type=text name=surname id=surname autocomplete=off / /form div id=ac style=display:none;border:1px solid black;background-color:white;/div script type=text/javascript language=javascript charset=utf-8 // ![CDATA[ var a_c = new Ajax.Autocompleter('surname','ac','suggest.cfm', {}); // ]] /script /body /html and the suggest.cfm page is below cfsilent cfparam name=form.surname default= type=string cfquery datasource=dsnhere name=suggestions SELECT surname FROM contacts WHERE surname LIKE ORDER by surname ASC LIMIT 10 /cfquery ol cfoutput query=suggestions li#suggestions.surname#/li /cfoutput /ol /cfsilent Kind Regards, Ian ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:312439 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4