NetTalk Central

Author Topic: Automatically call browse lookup from form only if validation fails  (Read 4131 times)

ozejohn

  • Jr. Member
  • **
  • Posts: 87
    • View Profile
    • Email
Hi,

I don't want operators to have to click on lookup buttons. I want the related browse window to just display if the value they enter is incorrect.
When validation fails for a field on a form with a lookup I want to call the browse to do a lookup automatically when they tab out of the field.

For example say we have an order form with a customer field that has a lookup button. The operator enters a customer code and presses tab. If the customer code is invalid I want to trigger a lookup in select mode. One of two things happens :-
- The operator can enter a valid customer and continues to the next field,
- They enter a invalid customer in which case the customer select browse displays asking them to select a valid customer, 

Can anyone give me a hint as to how to do this. I looked through the examples but could not see any that automatically call a browse if a lookup fails.

ozejohn

  • Jr. Member
  • **
  • Posts: 87
    • View Profile
    • Email
Re: Automatically call browse lookup from form only if validation fails
« Reply #1 on: November 09, 2008, 02:57:25 PM »
Hi,

I am thinking I might be able to handle this. Something like the way a lookup is handled when the Auto-lookup on insert checkbox is ticked. I could :-
- set a session variable to indicate a lookup is required when validation fails on a field that requires a lookup,
- exit from the form in a way that causes the form to refresh,
- when the form is being rebuilt check to see if a lookup is required using the session variable I set above. At the same point where the Auto-lookup on insert code is being built.,

To try this out I need to know how to return from the form in a way that makes it draw again. Is there a ans return value I can set to make this happen?

ozejohn

  • Jr. Member
  • **
  • Posts: 87
    • View Profile
    • Email
Re: Automatically call browse lookup from form only if validation fails
« Reply #2 on: November 15, 2008, 02:38:45 PM »
Hi,

I have looked into this further and found the problem appears to be due to all lookup buttons having the same id and name properties on the generated page. I can't work out how to use the javascript command document.getElementById to send a click to a lookup. It just returns the id of the first lookup buttons. As a result the following always clicks the first lookup button :-

<script type="text/javascript">
document.getElementById('[lookup button id]').click()
</script>

I am converting clarion desktop apps over to nettalk web server apps. The users expect to enter a code then have the lookup appear without clicking the lookup button if the code entered is invalid. Just as it does for Clarion destop apps.

This is quite crucial to me. Any suggestions on a workaround for this problem would be greatly appreciated.

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Automatically call browse lookup from form only if validation fails
« Reply #3 on: November 15, 2008, 10:37:08 PM »
Hi John,

The solution to your request is complicated because you are fundamentally mixing asynchronous , and synchronous things here. And in short, the effect you're looking for is not gonna be easy to do.

Ironically the effect is easier in the WebBuilder app precisely because that's "all synchronous".

At it's core, the problem is that you can only pass html, not JavaScript, back to the page when you're doing an async update. If you could pass back JavaScript then you'd be ok. Alternatively you need to do the validation on the client-side, and then use JavaScript to click the button.

I'm not sure what your timing requirements are for this feature, but I'll add it to the list for NetTalk 5.

Cheers
Bruce


ozejohn

  • Jr. Member
  • **
  • Posts: 87
    • View Profile
    • Email
Re: Automatically call browse lookup from form only if validation fails
« Reply #4 on: November 16, 2008, 01:02:44 PM »
Hi Bruce,

Thanks for that. This is a critical requirement for my customers.

I will give it a try when nettalk 5 comes out.