dtv995719
2013-12-13 13:31
浏览 20

在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.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • douheng8629 2013-12-13 14:03
    已采纳

    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 !!;)

    点赞 打赏 评论
  • dqrqp8492 2013-12-13 13:33

    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".

    点赞 打赏 评论

相关推荐 更多相似问题