I have a form field that needs to hold "firstname lastname <emailaddress>" and 
I would like to use an autosuggest event to make it work. The problem is the 
angle brackets: I can get the autosuggest list to look right if I send it the 
suggested values using &lt;/&gt; but then it returns the &lt;/&gt; inside the 
field content. Is there some javascript I can use to replace the returned value 
with the version that uses the real angle brackets? 

Here's the test version of the code I'm using, adapted from the cf docs:

<html> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> 
<head> 
    <cfajaximport tags="cfinput-autosuggest"> 
    <script> 
          var init = function() 
          { 
                        autosuggestobj = 
ColdFusion.Autosuggest.getAutosuggestObject('nameemail'); 
                        autosuggestobj.itemSelectEvent.subscribe(foo); 
          } 
          var foo = function(event,args) 
          { 
                var msg  = ""; 
                msg = msg + "Event: " + event + "\n\n"; 
                msg = msg + "Selected Item: " + args[2] + "\n\n"; 
                msg = msg + "Index: " + args[1]._nItemIndex + "\n\n"; 
                var newmsg = msg.replace("&lt;","<"); //just playing w/"replace"
                var newnewmsg = newmsg.replace("&gt;",">");
                alert(newnewmsg); 
          } 
          var getName = function(){ 
                return ["Joe Smith &lt;[email protected]&gt;","Jane Smythe 
&lt;[email protected]&gt; ","Jon Gggg &lt;[email protected]&gt;","Clyde Farmer 
&lt;[email protected]&gt;","Alka Seltzer 
&lt;[email protected]&gt;","Pendant Hang &lt;[email protected]&gt;","Penny Utah 
&lt;[email protected]&gt;","Amy Winston &lt;[email protected]&gt;"]; 
          } 
    </script> 
</head> 
<body>
<center>
    <h3>Attaching an event handler to the autosuggest object</h3> 
    <cfform name="mycfform" method="post" > 
         Name:<br />
         <cfinput 
                type="text" 
                name="nameemail" 
                size=40
                autosuggest="javascript:getName({cfautosuggestvalue})" 
                autosuggestMinLength=1 
                autosuggestBindDelay=1> 
          <i>first last &lt;email&gt;</i>
          <cfset ajaxOnLoad("init")> 
    </cfform> 
</center>
</body> 
</html> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:348037
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to