我有這個輸入字段:如何執行的第一個PHP函數不是JavaScript功能onclicking/submiting一個提交按鈕
<input type="submit" name="rregjistro" value="Rregjistro Tani Te Dhenat" onclick="openmodal()" >
我想先在PHP執行POST腳本,並比使用JavaScript來打開一個模式彈出功能。
你能幫我嗎! 在此先感謝!
我有這個輸入字段:如何執行的第一個PHP函數不是JavaScript功能onclicking/submiting一個提交按鈕
<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');
})
)
考慮使用ajax – utdev
運行Ajax查詢。然後在回調 - 打開彈出。 – user4035