Concatenate Object & String

Hi

I’m writing a standard method for keyword search where the value entered in the global keyword field has to be searched in number of different fields. I’m just trying to simplify the code

Main method called after entering the keyword:

if ( globals.srchKeyword != null && globals.srchKeyword != '')
{
   frmObj1 = forms.myForm;

   frmObj1.controller.find();
   
      var searchFldArray = new Array('first_name', 'last_name', 'job_title', 
                                     'address1', 'address2', 'address3', 'address4', 
                                     'city', 'country', 'email', 
                                     'industry','status', 'website'
                                      );
      globals.nav_commonScripts('setKeywordSearchRequests', searchFldArray);
   recordCount = frmObj1.controller.search();
}

Steps in ‘setKeywordSearchRequests’

case "setKeywordSearchRequests":
   searchFldArray = param2;

   frmObj1 = forms.myForm;
   var i;
   for (i=0; i < searchFldArray.length; i++) {
      searchFld = searchFldArray[i];

      frmObj1.controller.newRecord();  
      frmObj1.searchFld = "%" + globals.srchKeyword + "%"; 
   }
break;

The idea is to loop through field array given as argument and make the (OR) find requests. This is working if I directly specify a field name of the form but not when I concatenate the frmObj1 with the array value

I think there must be some concatenate function like eval or etc.. But I can’t clearly understand how it works. Can some one help me on this??

Thanks
Ahmad
Hong Kong

It should work when you change your code into this:

frmObj1[searchFld] = "%" + globals.srchKeyword + "%"; 

Excellent!!! :D

It worked… :)

I have been struggling with this for more than 3 hours.

Thanks a lot Patrick