0
在下面的代碼中,對話框的兩個按鈕都是爲了提交表單。但是,如果點擊對話框中的按鈕,則不提交。如果用戶選擇是,我們需要發送一個值到發佈頁面。請幫我解決一下這個。表單提交在jquery對話框中不起作用
<form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post" name="edit_billto" id="edit_billto">
<input type="hidden" name="option" value="com_phpshop" />
<input type="hidden" name="page" value="<?php echo $next_page; ?>" />
<input type="hidden" name="next_page" value="<?php echo $next_page; ?>" />
<input type="hidden" name="Itemid" value="<?php echo $Itemid; ?>" />
<input type="hidden" name="autoship_flag" id="autoship_flag" value="0">
<input type="submit" id="bill_sumbit" class="button" name="submit" value="<? echo _E_SAVE ?>" <? echo $submit; ?> />
</form>
Jquery的一部分
<div id ="alert" style="display:none"> <p> This address is used in autoship.
You need to change the address in autoship too?
</p></div>
<script>
$(document).ready(function() {
$("#alert").dialog({autoOpen: false,
modal: true,
buttons: {
No : function(){
isconfirm = true;
//$("form[name='edit billto']").unbind('submit');
$("#edit_billto").submit();
$(this).dialog("close");
//$("form[name='edit billto']").unbind('submit').submit();
},
Yes: save_info
},
resizable: true,
height: "auto",
width: "auto",
closeOnEscape: false,
title: "Autoship Update"
});
});
var isconfirm = false;
$("form[name='edit_billto']").submit(function(e) {
//alert(isconfirm);
if(isconfirm === true){
return true;
}
if(isconfirm === false){
e.preventDefault();
$("#alert").dialog("open");
}
});
function save_info(){
isconfirm = true;
$("#autoship_flag").val("1");
$("form[name='edit_billto']").unbind('submit');
$("form[name='edit_billto']").submit();
}
</script>
請添加您的html部分,因爲它可以是一個錯誤的選擇器;) – MarcelD
你可以把你的代碼在jsbin? –
@MarcelD我已經添加了html部分。請看看 – Thejas