As mentioned in the question above, I'm trying to set a variable in my javascript as the value of the user's username. This is how my code is set up:
function submitApproveModal(){ this_file = currentFile; var approvers = ""; if(document.getElementById('approvers').checked){ approvers = '<?php $_SESSION['username'] ?>'; } approveFileAjax(this_file.uid, approvers); }
I know this is not how it works and was wondering how I could rewrite my code so that the approver equals the user's username?
You just forgot about "echo":
But as mentioned before, mixing Javascript and PHP is a bad idea.