Page 1 of 1

Execute alert from php function

Posted: Tue Sep 20, 2005 9:15 pm
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>

Posted: Tue Sep 20, 2005 9:36 pm
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()

Posted: Tue Sep 20, 2005 9:39 pm
by facets

Code: Select all

function updated() {
	echo "<script language=\"JavaScript\">alert('Summary updated!')</script>";
}

Posted: Wed Sep 21, 2005 3:19 am
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.