This topic is locked
[SOLVED]

 Ajax Warning of Duplicate record?

6/4/2014 8:27:20 AM
PHPRunner General questions
A
Anapolis author

I have a "feedback" table where I want to warn or intercept via an Ajax query if a User has selected a field value in the related Form that matches a record already stored in this table.
I don't want the User to go through the trouble of filling out the whole form and only THEN learning on Submit that their time was wasted on creating a Duplicate record in this table that will not be saved.
For the Feedback Table Form I use the Query Wizard and apply it to the field "business_id".

The lookup table is a different table of these businesses.

The actual value from this table is a numeric "business_id"

The display value is the associated Name of the business
The actions would be:

  1. As soon as the user of the Feedback Form selects the name of a business in the Ajax popout field a query is launched via Ajax for this "business_id" value in the Feedback table.
  2. the User gets a Warning window if this immediate behind-the-scenes search finds a record already saved in the Feedback table with the same "business_ID"
    This would be similar to website forms where applying for a new account username triggers a popup message that "This Username is already taken, please try again".
    So far I cannot find the process in Help or Tutorials that could accomplish this.
    Thank you for pointing me in the right direction!

Sergey Kornilov admin 6/4/2014
A
Anapolis author 6/4/2014
A
Anapolis author 6/4/2014

WAIT!
This technique works perfectly EXCEPT it only works if the value is already known, such as a business ID, and typed into a field.
THEN the javascript and the lookup do their job and I immediately get back a message that this "business ID" has already been detected in the Feedback table.
But, if the value is selected from an ajaxed list of values set up by a custom wizard (as it HAS to be) then the javascript detection does not get engaged as it would if the value was typed in and the User tabs down to enter other fields.
The javascript 'blur' will not work on anything but a value physically typed into the field and then triggered by a tab or enter or mouse click into another field.
Is there a javascript state change other than 'blur! that could be invoked by choosing the value from a query wizard "Edit box with AJAX popup" action?

A
Anapolis author 6/4/2014

NOW WORKING!
I changed the javascript in this line from 'blur' to 'change' referencing the field "art_kdnr" (business id number goes here)

ctrlArt_kdnr.on('change', function(e) {


Now I can use the Query Wizard AJAX lookup function with concat values to help identify the business by name and location.
Selecting from that list almost immediately adds a warning message in the line below that field if the matching business id exists in feedback table.
Works great! Thank you, Sergey!

J
jianwong 7/28/2014



NOW WORKING!
I changed the javascript in this line from 'blur' to 'change' referencing the field "art_kdnr" (business id number goes here)

ctrlArt_kdnr.on('change', function(e) {


Now I can use the Query Wizard AJAX lookup function with concat values to help identify the business by name and location.
Selecting from that list almost immediately adds a warning message in the line below that field if the matching business id exists in feedback table.
Works great! Thank you, Sergey!


I followed the steps and tried using this method on Invoice add new item, but it won't prompt with error message when value selected is duplicate.