这是代码:
<form method="post" id="cp_ind_form">
// lots of input fields!
<input type="submit" name="update_submit" value="Update" />
<input type="submit" name="delete_submit" value="Delete" onclick="deleteConfirm()" />
</form>
scripts.js(确认此文件已连接到上面的页面)
(function deleteConfirm() {
var s = document.getElementById('confirm');
s.onchange = function() {
var yes = confirm('Do you really want to delete this location?');
if (yes) {
var f = document.getElementById('cp_ind_form');
f.submit();
}
}
})();
}
这让我发疯。这样的基本功能在这里不起作用?我基本上是从我拥有的其他代码中复制它,这没有什么不同。有人可以确认我是否遗漏了一个小细节吗?