我有一種情況,我試圖創建更新/刪除面板。我目前在刪除面板工作,並決定我想要使用相同的控件更新面板。我能看到這個工作的唯一方法就是如果確認按鈕可以選擇按下哪個按鈕。我似乎無法弄清楚如何做到這一點。有沒有辦法做到這一點,而不用創建一個全新的彈出菜單與不同的按鈕和全部?動態Javascript
//請注意,這是未完成的代碼,我仍在試驗代碼,所以如果有什麼不清楚的地方,只要問一下,我會試着解釋。
的JavaScript
//execute popup
function popup() {
$("#popupbg").animate({ opacity: ".8" });
$("#delete, #update").click(
function() {
$("#popupbg, #popupbgitembg").show('fast')
});
}
//execute popup cancel
function popupcancel() {
$("#popupbg, #popupbgitembg").hide('medium');
}
//execute popup delete
function popupdel() {
$('execdelete').click();
var button = document.getElementById("<%= execdelete.ClientID %>");
button.click();
$("#popupbg, #popupbgitembg").hide('medium');
}
HTML(popupbg是背景)
<div id="popupbg">
</div>
<div id="popupbgitembg">
<ul class="popupbgitems">
<li id="lidelete" visible="false">
<asp:Label ID="lblpopup" runat="server" ></asp:Label>
Are you sure you want to delete?
</li>
<li></li>
<li>
<asp:Button ID="execdelete" runat="server" CssClass="invisible" OnClick="delSysGLDepts" />
<asp:Button ID="execupdate" runat="server" CssClass="invisible" OnClick="updateSysGLDepts" />
<asp:Button ID="butdelete" runat="server" Text="Yes" Width="70px" OnClientClick="javascript:scroll;popupdel();" Font-Size="11.5px"/>
<asp:Button ID="butcancel" runat="server" Text="No" Width="70px" OnClientClick="javascript:popupcancel();" Font-Size="11.5px"/>
</li>
</ul>
</div>
<li><asp:Button ID="update" Text="Update" style="font-size:11px" runat="server"/>
<asp:Button ID="delete" Text="Delete" style="font-size:11px" OnClientClick="javascript:popup('delete');" runat="server"/>
</li>
對於創建多個彈出式窗口,您嘗試避免有什麼特別的錯誤嗎?如果彈出窗口是一個簡單的確定/取消對話框,我會認爲有兩個簡單的彈出窗口比一個動態彈出窗口更容易。 – 2012-08-13 16:32:50
除了添加以上所有內容的確切副本外,不,我不認爲它有。只是想知道是否有辦法做到這一點,以便代碼可以坐得更乾淨(創建函數也是一樣),而不是額外的100行,唯一改變的就是更新/創建和另一個說刪除。 – user1512593 2012-08-13 16:38:24