PHP code in javascript function - GRID

I have a GRID with a dropdown-button. Depending the clicked value a function is called.

OnRecord:
{dropBS}=’ <div class=“w3-dropdown-hover w3-right”>
<button id=“DropBS” class=“w3-button w3-padding-small w3-teal”>+<span class=“caret”></span></button>
<div class=“w3-dropdown-content w3-bar-block w3-border” style=“right:0”>
<a href="#" onclick=“nok()” class=“w3-bar-item w3-button” value=1>nok</a>
<a href="#" onclick=“ok()” class=“w3-bar-item w3-button” value=3>ok</a>
</div>
</div>’;

OnScriptInit: functions declared ?>
<script type=“text/javascript”>
function ok() { CODE…
}

function nok() { CODE...
  }
&lt;/script&gt;

<?php

Now the question. I want to run some PHPcode in one of the JS-functions. To change the value of a table

sc_exec_sql(“UPDATE tblDoc SET Vervallen = 1 WHERE idDOC = 5;”);

What is the format to do so? Is this the right way to do so?

nobody has the same problem?

I have the same problem.
Did you solve it?

You cannot use PHP inside JS-function because the JS is running on the client device and PHP on your server.

You need to send the information to the server. You can do that with an Ajax call that will look like this

$.ajax({
url: ‘…/app/index.php’,
type: ‘POST’,
data: ‘Vervallen=1&idDoc=5’,
success: function(data){
},
error: function(data) {
alert(“Trouble”);
}
});

You need to create a blank app the will capture de data and save it

//onExecute

$Vervallen = $_POST[‘Vervallen’];
$idDoc = $_POST[‘idDoc’];

sc_exec_sql(“UPDATE tblDoc SET Vervallen = " . $Vervallen . " WHERE idDOC = " . $idDoc);