Intercept selection in AW.UI.Combo
Okay, I am using the stand-alone combo box to create an auto complete kind of combo that uses AJAX to get matches that include what the user is typing. These matches are parsed and the section of each option that matched is bolded.
Now, when I select an item from the drop-down, the item gets passed into the box. However, I need to strip out the <strong> tags. What's the best way to do this?
Here's the code:
- alphadog
Now, when I select an item from the drop-down, the item gets passed into the box. However, I need to strip out the <strong> tags. What's the best way to do this?
Here's the code:
vendorCombo.onControlTextChanged = function(text){
// length of text in combo must be at least three or more chars
if (text.length > 2) {
var r = new AW.HTTP.Request;
r.setURL("../internal/matchVendorNameSnippet.asp");
r.setRequestMethod("POST");
r.setParameter("NM", text );
r.request();
r.response = function( data ) {
if ( data.substr(0,5) != "ERROR" ) {
// bold the sections with the match
bld = new RegExp( "(" + text + ")", "gi" );
data = data.replace( bld, "<strong>$1</strong>");
// split into array and remove the success marker
arr = data.replace(/SUCCESS:/, "").split("|");
vendorCombo.setItemCount( arr.length );
vendorCombo.setItemText( arr );
vendorCombo.setItemValue( arr );
vendorCombo.showPopup();
}
}
}
else {
vendorCombo.setItemCount( 0 );
vendorCombo.setItemText( null );
vendorCombo.setItemValue( null );
vendorCombo.hidePopup();
}
}
- alphadog
Paul Tiseo
November 17,