if(.....){
?>
<script>nomefunzione();</script>
<?php
}