savsoft
asked on
How to Call javascript sunction through php
i want to call javascript function through php
<head>
<script language="javascript">
function freeplan(id)
{
alert(id);
}
</script>
</head>
<body>
<?php
if(condition)
{
}
else
{
javascript:freeplan(id);
}
?>
</body>
It Is not working..... Plz Tell me the way how to call javascript function
<head>
<script language="javascript">
function freeplan(id)
{
alert(id);
}
</script>
</head>
<body>
<?php
if(condition)
{
}
else
{
javascript:freeplan(id);
}
?>
</body>
It Is not working..... Plz Tell me the way how to call javascript function
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
you cannot call javascript function from PHP. PHP is server side (runs at server) and javascript is client side (runs in user browser).
If you want to call function from PHP, then you have to create a function in PHP. again this function is available to only PHP.
below code may help you...
If you want to call function from PHP, then you have to create a function in PHP. again this function is available to only PHP.
below code may help you...
function freeplan(id)
{
alert(id);
}
</script>
</head>
<body>
<?php
if(condition)
{
//some logic here
}
else
{
?>
<script language="javascript">
freeplan(<?php echo $iid; ?>);
</script>
<?php
}
?>
</body>
OR
<head>
<script language="javascript">
function freeplan(id)
{
alert(id);
}
</script>
</head>
<body>
<?php
if(condition)
{
}
else
{
<?php echo "<script>freeplan('123');</script>";
}
?>
</body>
ASKER
Thank You All.... All Answer accepted
Open in new window
Hope that helps