在PHP的同一页面上显示java脚本的警报[关闭]

在PHP的同一页面上显示java脚本的警报[关闭]

问题描述:

i am trying to show an alert of java script on a same i mean the below code

echo "<script type='text/jscript'>alert('Wrong Email!!.')</script>";

for example after checking the form if something wrong this message appear on the same page ,right now i can handle this message on a blank page & after that again with redirect code redirect to the same page ,but this is not the one which i want !!! i want this message appear on the same page of P H P.

i find the solution for this problem I,MYSELF. we can send the submit values to another page but after checking in that page you can send back a value & result by query into the same page & show up the result ..look!

if($email=null){

echo ("document.location.href='../home.php?result=wrong';"); }

and on home page you can show the message like this !

if(isset($_GET['result'])){if($_GET['result']==wrong){ echo "<script
type='text/jscript'>alert('Wrong Email!!.')</script>";}}

That's it !!;)

Use it in href:

<a href="javascript:alert('Wrong Email!!.');">

Otherwise you need it in a Button, a.e. when the Form is Submitted:

function showAlert() {
    if(foo = bar)
        alert('Wrong eMail!');
}

<input type="submit" value="Click Here" onClick="showAlert();">

If you just want to see an Alert PopUp after Pageload, go with the HTML Body Tag and "onLoad".