i have this input field:
<input type="submit" name="rregjistro" value="Rregjistro Tani Te Dhenat" onclick="openmodal()" >
我希望首先在PHP中执行POST脚本,然后使用JavaScript函数打开一个模态弹窗。
你能帮我吗!提前感谢你!
i have this input field:
<input type="submit" name="rregjistro" value="Rregjistro Tani Te Dhenat" onclick="openmodal()" >
我希望首先在PHP中执行POST脚本,然后使用JavaScript函数打开一个模态弹窗。
你能帮我吗!提前感谢你!
使用PHP无法进行点击操作,因为表单提交是在客户端完成的,即在您的浏览器中完成。浏览器中的此类事件可以通过JavaScript或其他客户端语言执行。
<form ... >
<input type="submit" name="rregjistro" value="Rregjistro" />
<!-- remove onclick attribute for now -->
</form>
<div id="myResult"></div>
<script>
$(function(){
$("input[name=rregjistro]").click(function(){
// url needs to belong to your domain
$.ajax({url: "/your_url_path", success: function(result){
$("#myResult").html(result);
open();
}});
});
});
</script>
你仍然需要首先编写一个 JavaScript 函数。
在 jQuery 中,可以这样写:
function open() {
$.post('http://url', $('#form').serialize(), function() {
alert('popup goes here');
})
)