Changes

AJAX - Function - LiveSearch

1,815 bytes added, 21:08, 27 December 2012
no edit summary
LiveSearch is the ability to use AJAX to lookup as if it was a search facility. This is commonly seen on the likes of Google's search page. You being typing and it starts to seek out answers. Now bxp software databases can be used for LiveSearch. A text box can be used to LiveSearch on any field in an existing database.
 
 
== Step 1. Create and populate the data source campaign ==
This is the campaign from which the data comes. This is the campaign you will be searching on. With that campaign coplete and populated, identify the field you want to search on. For this example we'll say that our source campaign is Campaign 41. The field within that campaign that we wish to search on is strCDA_41_field_0_4.
 
 
 
The first line calls the function every time a letter is entered into the box. The second div is where the output of the function goes.
 
 
 
== Step 3. We put in the JavaScript block. ==
//LiveSearch fields
aryAjax_Settings[25] = "strCDA_312_field_0_2"; //Field to be updated get Id when live option button clicked
aryAjax_Settings[26] = "fnUpdate"; //Function to be performed after update
aryAjax_Settings[27] = "strCDA_312_field_0_2_TextDisplay"; //Field to get Description when button clicked
fn_Ajax_BE_Process();
}
</syntaxhighlight>
 
 
Now to explain the key elements of whats going on.
Line 8 gets the current value being searched for.
Line 9 where the results go.
 
 
We don't want to do a look up with too little values.
Line 11, if nothing typed in, do nothing.
Line 12, do nothing unless we have more than 1 letter.
Line 18 on, do the lookup.
 
 
Line 18. Set the system
Line 19 and 20 do not need to be set as we use the users log in details set in lines 36 through 38.
 
 
Line 22. The Database being LiveSearched
Line 23. The field to be searched against.
Line 24. As we may want to return multiple answers and not use exact matches, we add an * which will return all solutions beginning with whatever is typed in the box. You could put * at the start and then all reasults that END with what is typed would be located. A * front and end would match all cases.
 
 
Line 26. As can be used to exclude answers if needed. -1 does no limiting
Line 27. No click through
Line 28. The div that will hold all the results
Line 29. Which engine of the Self Referencing to use.
 
 
Line 31. At a minimum the Id. The following fields are the returned data fields. This engine does not use the Campaign Search display fields.
Line 32. Column headings if need.
Line 33. The fields to actually display on screen.
 
 
Line 41. When the button to choose a LiveSearch candidate is clicked where should the Id be stored
Line 42. When the function has finished storing the data, what further function should be executed. This is a handy optional continuation to allow you to extend the funtionality of a click easily.
Line 43. What field will take the text of the item, if needed.
 
 
Line 53 to 55 show the extended function ready to use. In this case just performs a simple Alert to screen.
7,528
edits