In short, no. Javascript is client-side and run long after the php script has executed - they cannot talk to each other. Perhaps you could use JS to reload the page, sending a variable in the URL. IE your javascript would be something like:
if(someCondition) window.location =...