点击HTML表单提交使用PHP后弹出 [英] popup after clicking the html form submit using php

查看:431
本文介绍了点击HTML表单提交使用PHP后弹出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个提交按钮证书副本,当我点击它应该显示一个弹出按钮。
下面是我的html代码。

  print< script src ='https:// ajax。 googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js'></script>; 
print< form action ='details.php'name ='copy'method ='POST'target ='_ blank'>;


print< input type ='hidden'name ='certificate_name'value ='$ certificate_name'>;
print< input type ='hidden'name ='certificate_id'value ='$ certificate_id'>;

$ b print< input type ='submit'name ='certificatecopy'id ='certificate'value ='Certificate Copy'>;

打印< / form> ;

而我的弹出式代码是

  print'< script> $(document).on('click','#certificate',function(){val = confirm('你想创建一个新证书吗?' ); 
alert(val);
if(val)
{
alert('proceed');
return true;
}
else
{
alert('Dont proceed');
return false;
}
});< / script>;

我的问题是,当我第一次单击按钮时,弹出框不会出现。但是当第二次点击该按钮时,弹出框出现。问题是什么。当第一次点击按钮时,我需要弹出窗口。请求帮助。

解决方案

在向服务器发送请求之前,您想要求确认客户端吗?

如果你使用Bootstrap,你可以试试我制作的一个小小的jQuery插件, https://github.com/delboy1978uk/bs-delete-confirm 。它不需要仅仅用于删除,它只是被命名的,因为它是最常用的情况。



您所做的只是为您的链接添加一个CSS类:

 < a href =/ whereverclass =confirm> Do stuff!< / a> 

和javascript:

  $(document).ready(function(){
$('。confirm')。deleteConfirm();
});

现在,当您单击链接时,JS拦截它,启动引导模式窗口, ,您的超链接。



您也可以将选项传递给deleteConfirm()方法:

  {
标题:请确认,
body:您确定要执行此操作?,
ok_text:继续,
cancel_text:Back,
log:false
}

这有助于!如果你不使用Bootstrap,那么值得加入你的项目是非常值得的!以下是模式功能的链接:
https://getbootstrap.com/docs /3.3/javascript/#modals


I have a submit button"Certificate copy" when i clicked the button it should show a popup. The below one is my html code.

print "<script src='https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js'></script>";
print "<form action='details.php' name='copy' method='POST' target='_blank'>";


        print "<input type='hidden' name='certificate_name' value='$certificate_name'>";
        print "<input type='hidden' name='certificate_id' value='$certificate_id'>";


        print "<input type='submit' name='certificatecopy' id='certificate' value='Certificate Copy'>";

print "</form>" ;

and my code for popup is

    print "<script> $(document).on('click','#certificate',function(){val = confirm('Do you want to create a new certificate?');
alert(val);
if(val)
{
     alert('proceed '); 
     return true;
}
else
{
   alert('Dont proceed');
   return false;
}
});</script>";

My problem is, when i click the button at first time the popup box doesn't appear. but when the button clicked second time, the popup box is appear. what is the problem. I need the popup when the button clicked first time. please help.

解决方案

You want to ask for the confirmation Client side before sending a request to the server?

If you use Bootstrap, you can try a little jQuery plugin I made, https://github.com/delboy1978uk/bs-delete-confirm. It doesn't need to be used solely for deletion, it's only named that since it's the most used case.

All you do is add a CSS class to your link:

<a href="/wherever" class="confirm">Do stuff!</a>

And the javascript:

$(document).ready(function(){
  $('.confirm').deleteConfirm();
});

Now when you click the link, the JS intercepts it, launches a bootstrap modal window, and upon confirming, follows your hyperlink.

You can pass options in to the deleteConfirm() method too:

{
  heading: "Please confirm",
  body: "Are you sure you wish to perform this action?",
  ok_text: "Proceed",
  cancel_text: "Back",
  log: false
}

Hope this helps! If you don't use Bootstrap, it's well worth addingto your project! Here's a link to the modal functionality: https://getbootstrap.com/docs/3.3/javascript/#modals

这篇关于点击HTML表单提交使用PHP后弹出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆