Skip to content

Instantly share code, notes, and snippets.

@Mauryashubham
Last active August 3, 2017 09:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mauryashubham/f32fc10a4838afaf1d7f9b1e46bcf6dc to your computer and use it in GitHub Desktop.
Save Mauryashubham/f32fc10a4838afaf1d7f9b1e46bcf6dc to your computer and use it in GitHub Desktop.
Call a HTML JavaScript Function from PHP using echo
/**
@author : Shubham Maurya,
Email id : maurya.shubham5@gmail.com
**/
Hi all , Welcome to shubhammaurya.com , Today we are going to discuss ,
how to Call HTML JavaScript Function from PHP using echo
1.Make a file in notepad and save it as index.php and paste the below code.
<?php
echo "<script> window.onload = function() {move();}; </script>";
?>
<!DOCTYPE html>
<html>
<head>
<style>
#myProgress {
width: 100%;
background-color: #ddd;
}
#myBar {
width: 10%;
height: 5px;
background-color: #4CAF50;
text-align: center;
line-height: 30px;
color: white;
}
</style>
</head>
<body>
<p id='myP'></p>
<script>
function move() {
document.getElementById("myP").innerHTML = "Successfully Invoked.";
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment