You cannot do that.
PHP is executed on your server. Javascript on the otherhand is executed on your client’s machine in the browser.
There are two different execution context. While you can pass a PHP variable into Javascript, you cannot do the opposite since PHP is executed first and the JavaScript code is the output of your PHP code.
If you want to send a Javascript variable to PHP, you have to do with in a separate request either via a cookie or an AJAX request. Here’s an example:
$.ajax({
url: 'receivingScript.php',
data: {'value': $("#ct100").text()}
});
3
solved Pass Javascript var into PHP var