Click here to Skip to main content
15,905,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
PHP

i have defined a function in java scipt.
Now I want to call that function from echo'';statemnt onclick of hyperlink.

What I have tried:

PHP

';
echo'<html>';
echo'<head>


.main_div
{

border: 2px solid green;
display:block
margin:auto;
}
.question_div
{
border: 2px solid yellow;

}



<script type="text/javascript">

function change_colour(divID)
{
alert("hello");
var id = divID;


}

</script>
</head>';

echo'<body>';

echo'
';
echo'';
for($i = 1;$i<=4;$i++)
{
echo'';

echo'';
echo'';

echo'';
}
echo'
';




echo'</body>';
echo'</html>';
?>
Posted
Updated 19-Nov-16 11:22am

1 solution

You can't. Your PHP is running on the server. Sends the HTML page, including the javascript you have in the page, to the client and the client executes the script.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900