Click to See Complete Forum and Search --> : Delete Box Confirmation


BigRed
09-08-2003, 09:52 AM
Hi. I have javascript code that pops up a confirmation delete box to confirm that I want to delete a particular record out of a grid. This works fine:

function window.onload() {
var btn = document.all("fpgData_Delete")
btn.onclick = Delete;
}

function Delete() {
var msg = "Are you sure you wish to delete the selected row?";
if (confirm(msg))
{
__doPostBack(fpgData.id, "Delete"); }
}

The problem is that I have 2 grids to run this with (and I only have 1 window.onload function). I have created a try...catch, but it doesn't seem to work. Can someone tell me what if this is the easiest way or another way to handle this? Thanks in advance for any help!!

BR

BigRed
09-08-2003, 12:24 PM
Here is my try...catch:

function window.onload() {
try {
var btn_Par = document.all("fpgParent_Delete");
btn_Par.onclick = DeletePar;
}
catch {
}
try {
var btn_Chi = document.all("fpgChild_Delete");
btn_Chi.onclick = DeleteChi;
}
catch {
}


function DeletePar() {
var msg = "Are you sure you wish to delete the selected row?";
if (confirm(msg)) {
__doPostBack(fpgParent.id, "Delete"); //if you want the delete to happen
}
}

function DeleteChi() {
var msg = "Are you sure you wish to delete the selected row?";
if (confirm(msg)) {
__doPostBack(fpgChild.id, "Delete"); //if you want the delete to happen
}
}