Hi everyone,
I'm building a custom search field, and I'm trying to solve the issue of the text in the search field being searchable. Since the search field is on every page, the customer will get a lot of unwanted returns.
My solution was to blank the field using a custom script and "on blur" command.
This went in custom format for the text field:
if( (event.commitKey == 2)&& !/^\s*$/.test(event.value))search.query(event.value, "ActiveDoc");
event.value = " ";
And then I added a "clear field" on blur command - This reset the form before the search engaged, allowing it to proceed normally. It properly searches the document bypassing the search field, which is now empty. This all works when a user pushes the "enter" key.
This is all well and good, but I also have a search button that engages the query from the text field (it also clears the field after it runs with a "mouse up" action, duplicating the fix above).
The problem? Since I've got the "On Blur" Action on the text field, every time you click the search button it clears the search field before the query can run. So it searches nothing.
Is there a way I can keep the data being entered into the search field (perhaps in a hidden text field) so that my search button can call on THAT field instead? This would solve pretty much everything. But I can't figure out how to get that hidden text field to keep its data. Is there a way for it to hang onto the data beofre the event.value = " " blasts it?
Phew - Hope everyone followed that. Thanks!
if(event.willcommit)
{
... your code ...
}
This way the value of the field is never set.
copy the data to a document level variable. The data is then accessible to all scripts on the document.
this.MySearchString = event.value;
Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script