how to call php function in javascript ?

Where is the javascipt? In an external javascript file or in a page...eg file.php?

If it's in the same file why not just put <?php function(); ?> in the javascript where you need it?

kind of vague, but the only time I use javascript with php is when I need a value from a database.

?>
//ex: 
<script>
$id =  row['id'];
var id = "<?php echo $id; ?>";
</script>

//you can use a function if it echo/returns a value

hope this helps

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.