0
我有一張圖片我想用作連接中表格行的刪除連接。圖片點擊通過ok進行刪除或取消HTML Javascript
我想集成一個確認刪除消息框使用JavaScript。
下面是錶行:
<td>
<input type="image" name="submit" src="static/img/32/critical.png" alt="Delete Connection" onclick="(<%# Eval("id").ToString%>);clearText(<%= result.ClientID%>); CopyId(<%# Eval("id").ToString%>); return Message(<%# Eval("id").ToString%>)" />
</td>
這裏是腳本:
<script>
function Message() {
var txt;
var ok = confirm("Are you sure you want to delete this connection");
if (ok == true) {
return true;
txt = "Connection Deleted!";
(<%# Eval("id").ToString%>);clearText(<%= result.ClientID%>); CopyId(<%# Eval("id").ToString%>);
} else {
return false;
txt = "Cancelled";
}
document.getElementById("PopUp").innerHTML = txt;
}
</script>
和
<p id="PopUp"></p>
此刻當我點擊它只是刪除圖像排和連接而不問我。我希望它要求確認並採取相應行動。
如果爲true,則運行刪除,如果沒有則取消。
掙扎了一下,所以任何幫助表示讚賞。
我想你的代碼,但它仍然只是刪除了該行無任何消息框 – BarryWhite
我很抱歉。我剛剛更改了我的代碼。試試這個 –
,因爲當你在'if'中返回true或false時,它不會運行到'document.getElementById(「PopUp」)。innerHTML = txt;' –