I want to filter through existing records via text input so that I can populate a form with client’s data. It all works great with the exception of the initial page load. When the page opens the first record shows up in the fields.
The initial page opens and shows the first record’s data…
I tried something similar… I hid the client fields until there was an entry in the search field. The only problem that I could think of during that trial was what would happen if the client tried to add a new service request without searching for a client. The first record data would be inserted without it being seen, and the result would lead to the wrong client info would be associated with the new request data.
I guess there are probably a number of ways you could achieve this (i presume you want the fields to be blank when it loads?)
Could you put value in the field instead of the placeholder text, i.e. Type company name, or first name, or last, name
No search would match that so would return no values. You could format it to look the same as the place holder text.
You could set up another query, so that the search input you have uses that to select the client ID and then sets that value to another variable. That variable is then what your main query has as the condition.
So search for name, name is found, sets client value on another variable that then populates all the data in your form. That way it will return no data until a client ID is selected through your search field.
As it stands at the moment, the CONTAINS condition will always return all results if its blank.
That’s just a couple of ideas, easier to work out when it is your own app and data through.
Thanks Phillip! I’ve tried all the conditions, i.e., IS NOT NULL, etc. I believe I will have to redesign the client’s database, or at least make a supplemental source to work with.
What if you simple add another condition in your query, you would need to rearrange the grouping a little bit but it could be done.
The condition would be something like
Clientid = Get.search
Use the toggle condition (just for this condition, not your other ones)
$_GET.search = " " (or maybe = NULL)
Basically the theory would be that when the search field is empty (i.e. when page loads) it would apply the condition of clientID = search field, which will return no values and the query would be empty, therefor not populating any data.
The moment the search file has some value in it, that condition would not apply and only the existing 3 conditions you have now would apply.
Something like this, but i have just mocked this up. I’m confident it would work though:
Agreed. I did try the ‘No Auto Load’ … unfortunately, it failed. I believe the trigger would have done the trick, but …
I decided to spring off a client list with a url link + id button. Then off to the form page with the query in hand to place the client’s id, name, address and email in their proper fields and …
It works.