I want to know is it possible to call a php function within javascript, only and only when a condition is true. For example
PHP is server side and Javascript is client so not really (yes I know there is some server side JS). What you could do is use Ajax and make a call to a PHP page to get some results.