Questions and discussion about developing processes and programming in PHP, JavaScript, web services & REST API.

Moderator: amosbatto

Forum rules: Please search to see if a question has already asked before creating a new topic. Please don't post the same question in multiple forums.
By sgkalluri
#790247
Hello everyone,

I have a textbox in a dynaform that is populated by execution of its related sql query (defined in the textbox control).

Is there a way by which I can prevent the execution of the query based on certain conditions when the DynaForm is loaded for the user?

Best wishes,
SGK
#790251
There is no way that I know to prevent an SQL query from happening when the DynaForm loads, but you can use JavaScript to clear the contents of the field after the query takes place:
if a textbox or textarea, then use this code:
Code: Select all
if ( /*some condition*/ ) {
   $("#myfield").setValue("");
}
If a dropdown, checkgroup, radiogroup or suggest box, then use this code to clear the list of options set by the SQL query:
Code: Select all
if ( /*some condition*/ ) {
   getFieldById("myfield").mergeOptions([]);
}

See: viewtopic.php?f=47&t=710111
#790254
Thanks a lot Amos!

I experimented by writing the SQL query in the following manner:

Select abc from def where (1 = @=xyz)

Where the @@xyz variable is set to 1 in JavaScript when certain conditions are met when the form is loaded and to any other value when those conditions are not met.

However, you are right. The query does have to execute. It just does not return a value.

Best wishes,
SGK

Hello amosbato, Trying to retake this conversatio[…]

Resta de valores con 2 textobox

Hola! Se replicó lo que estabas haciendo […]

Hello! If you did not find the mcrypt extension […]

Hello! You have a mistake in the url, the correct […]