Execute alert from php function

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
facets
Forum Contributor
Posts: 273
Joined: Wed Apr 13, 2005 1:53 am
Location: Detroit

Execute alert from php function

Post by facets »

hey gang..

any ideas on how I could do this without the button?
So i can execute it from calling a php function

<form><input type=\"button\" onclick=\"alert('Done!')\" value=\"Alert\"></form>
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Post by josh »

you can't call it from php because php parses before or during an http response, therefore php is no longer running by the time the browser renders the output, you could do something like

Code: Select all

onbodyload="javascript:whatever()
facets
Forum Contributor
Posts: 273
Joined: Wed Apr 13, 2005 1:53 am
Location: Detroit

Post by facets »

Code: Select all

function updated() {
	echo "<script language=\"JavaScript\">alert('Summary updated!')</script>";
}
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

if you want to do it without the button, just set it up in a <script></script>

Code: Select all

<script type=\"text/javascript\">
function alertText()
{
  alert('something');
}
</script>
Of course, you still need something to trigger that function, as the onClick did in your first post.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Post Reply