This topic is locked

if record exist js code

12/14/2011 5:48:06 PM
PHPRunner General questions
D
danaci author

hi,
my table is

name v(30)

k_number n(9)
is it possible?

add record onload event;
before record add control of

if record exist(name or other criteria)

js code and alert this record details?

I need this event code but not php.
regards.

C
cgphp 12/14/2011

Try to reformulate your question. It's not very clear and a bit confused.

D
danaci author 12/14/2011

dear christian,

on add record onload event,

if record exist alert ('bla','bla')

I need js code this operation.

regards.

C
cgphp 12/14/2011

In the "Javascript Onload" event of the add page, enter this code:



var ctrlField = Runner.getControl(pageid,'field_name');

var ctrlValue = ctrlField.getValue();

this.on('beforeSave', function(formObj, fieldControlsArr, pageObj){



//MAKE AN AJAX CALL TO CHECK IF THE RECORD EXISTS

$.ajax({

type: "POST",

url: "some.php", //the page where you check if the record exists

data: "value_to_check="+ctrlValue,

dataType: 'json',

success: function(res)

{

//You have to evaluate the json response from the the server

//If record exists return false else return true

}

});

});


In the some.php page make a query on your table to check if "value_to_check" already exists and return a json object.

D
danaci author 12/14/2011

thnx christian..