5 Replies - 11776 Views - Last Post: 22 April 2010 - 05:36 PM Rate Topic: -----

#1 Jnanada28  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 22-April 10

Display Javascript alert box in php

Posted 22 April 2010 - 03:24 PM

hi

I want to know how can use javascript alert box in php.
Attached File  upload_form.php (1.47K)
Number of downloads: 143

Attached File(s)



Is This A Good Question/Topic? 0
  • +

Replies To: Display Javascript alert box in php

#2 Scotty G  Icon User is offline

  • D.I.C Head

Reputation: 10
  • View blog
  • Posts: 59
  • Joined: 09-April 10

Re: Display Javascript alert box in php

Posted 22 April 2010 - 03:29 PM

try something like this in a button tag
echo "onclick=\"alert('hi');\"




or you could just throw the alert hi in some javascript tags
Was This Post Helpful? 0
  • +
  • -

#3 Scotty G  Icon User is offline

  • D.I.C Head

Reputation: 10
  • View blog
  • Posts: 59
  • Joined: 09-April 10

Re: Display Javascript alert box in php

Posted 22 April 2010 - 03:36 PM

an alert box just in script tag in php would like this
print "<script type=\"text/javascript\"> alert('hi'); </script>";



Hope this helps! :D
Was This Post Helpful? 0
  • +
  • -

#4 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6058
  • View blog
  • Posts: 23,495
  • Joined: 23-August 08

Re: Display Javascript alert box in php

Posted 22 April 2010 - 04:25 PM

What the other folks are getting at is this: PHP is run on the server, Javascript is run on the browser. PHP returns HTML and Javascript to the browser, so the only "support" PHP has for displaying a Javascript alert box is to add the Javascript into the HTML stream being returned to the browser.
Was This Post Helpful? 0
  • +
  • -

#5 CTphpnwb  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 2927
  • View blog
  • Posts: 10,114
  • Joined: 08-August 08

Re: Display Javascript alert box in php

Posted 22 April 2010 - 04:51 PM

Another way of thinking of this is that HTML, Javascript, and just plain text are all the same to php. These all do the same thing:

echo '<script type="text/javascript">document.write("<b>Hello world</b>")</script>';

echo '<b>Hello world.</b>';

?>
<b>Hello world.</b> 
<?php

Was This Post Helpful? 0
  • +
  • -

#6 LiDoNg_9_0  Icon User is offline

  • D.I.C Head

Reputation: 10
  • View blog
  • Posts: 159
  • Joined: 03-September 09

Re: Display Javascript alert box in php

Posted 22 April 2010 - 05:36 PM

echo "<script>alert(\"Yes I got it!\");</script>";
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1