Javascript Alert Box in PHP

By | 08/04/2012

Alert box in webpage is used to alert the user of the webpage. PHP is a sever side scripting language, so it can’t able to do alert box in client side( browser), this is the reason why we are integrating javascript in php coding.

 

First type of alert box by alert(“”);

Select Code
1
2
3
4
5
<script type='text/javascript'>

alert("This is alert box 1");

</script>

Second type of alert box window.alert(“”);

Select Code
1
2
3
4
5
<script type='text/javascript'>

window.alert("This is alert box 1");

</script>

Here is the coding, How Javascript is integrated with PHP coding? and displaying php values in javascript alert box.

$value is used inside the javascript

Select Code
1
2
3
4
5
6
7
8
9
<html>
<body>
<?php
$value=2500;

echo "<script type='text/javascript'> alert('The value of Computer is".$value." INR'); </script>";
?>
</body>
</html>

Output for the above PHP and Javascript coding.

 

 

Post By prasad (110 Posts)

Website: →

Connect

About prasad

Prasad K has written 110 post in this blog.

One thought on “Javascript Alert Box in PHP

Leave a Reply