Anyone figured out a way to highlight search words in a found set?
- david
var re = eval("/" + globals.search_string + "/gi");
return "<html>" + testplain.replace(re,"<b>"+globals.search_string+"</b>")+"</html>";
var re = new RegExp(globals.search_string, "gi");
return "<html>" + testplain.replace(re,"<b>"+globals.search_string+"</b>")+"</html>";
function performSearch(event) {
// Performs sub-string search on person
var s = '%' + globals.search_string + '%';
// Clear results and find by first name
controller.find();
name_first = s;
controller.search(true,false);
// Add surname results to search
controller.find();
name_last = s;
controller.search(false,false);
// etc
controller.find();
business = s;
controller.search(false,false);
controller.find();
email_1 = s;
controller.search(false,false);
// Takes focus back to search box so user can modify search immediately
elements.searchBox.requestFocus(false);
}
var re = new RegExp("("+globals.search_string+")", "gi");
return "<html>" + testplain.replace(re,"<b>$1</b>")+"</html>";
if (controller.find()) { // don't forget to test if you are allowed to search
name_first = s;
controller.newRecord();
name_last = s;
controller.newRecord();
// etc.
controller.find();
}
SELECT * FROM yourtable WHERE name_first = ? OR name_last = ? OR ...
function name_last_disp()
// Used for highlighting the search string in the results field
{
if(name_last != null)
{
var re = new RegExp("("+globals.search_string+")", "gi");
return "<html>" + name_last.replace(re,"<b>"+globals.search_string+"</b>")+"</html>";
}
}
function name_first_disp()
// Used for highlighting the search string in the results field
{
if(name_first != null)
{
var re = new RegExp("("+globals.search_string+")", "gi");
return "<html>" + name_first.replace(re,"<b>$1</b>")+"</html>";
}
}
function hilite(what)
// Used for highlighting the search string in the results field
{
if(what != null)
{
var re = new RegExp("("+globals.search_string+")", "gi");
return "<html>" + what.replace(re,"<b>$1</b>")+"</html>";
}
return what;
}
function name_last_disp()
{
return globals.hilite(name_last);
}
function name_first_disp()
{
return globals.hilite(name_first);
}
BulldogBen wrote:Wow, as easy as they hey, just a simple function with a sting passed in, thanks for pointing me in the right direction.
Let's take it a step further. If I have many fields on a form, each with a text label, and I want clicking the text label to do essentially the same thing, is there any way to reference the field name the text is associated with and pass that into a single method?
If that can't be done, could I intercept the right click event on the field and get the field name that way to pass into my totally general method?
Hope the question makes sense, just don't want to write the same code 10 times putting different field names in each time + I'm sure there's a great general lesson to be learnt.
/**
* Perform the element default action.
*
* @param {JSEvent} event the event that triggered the action
*
*/
function onAction(event) {
globals.doSomeGenericStuff(field);
}
function doSomeGenericStuff(event) {
var frm = forms[event.getFormName()];
var field = event.getSource();
var value = forms[event.getFormName()].foundset.getDataProviderValue(field.getDataProviderID());
// etc..
}
Users browsing this forum: No registered users and 6 guests