Quantcast
Channel: DaniWeb Solved Topics
Viewing all articles
Browse latest Browse all 587

simple js program

$
0
0

program1.php

<html> <header> <script>

function myFunction(p1, p2) {
    return p1 * p2;
}
document.getElementById("demo").innerHTML = myFunction(4, 3);   
</script> </header> <body> <div id="demo"></div> </body> </html>

I don't understand why the above code does not show any value?

and why this one does?

program2.php

<html> <body> <div id="demo"></div> <script>
    function myFunction(p1, p2) {
return p1 * p2;
}
document.getElementById("demo").innerHTML = myFunction(4, 3);
</script> </body> </html>

Why I cannot stated the js first then calling it? Why calling it first then stated the js?


Viewing all articles
Browse latest Browse all 587

Trending Articles