Click to See Complete Forum and Search --> : onClick alert for radio button based on state of dynamically created checkbox


kermitpiper
12-14-2003, 10:23 PM
Hello,

I have a web page that has records that are dynamically created from a database. There are two tables, one with its own form, but both forms are looping thorugh exactly the same record set. On Form 1, there is a radio button that the users can click to delete a record, but I need to prevent the users from deleting a record on Form 2 if the checkbox on Form 2 is unchecked (checked == false). I have two functions, one for deleting (which works) and one I'm trying to use to prevent deleting (which I can't get to work), which I have as part of the onClick event for my Response.Write line:


function deleteMessage()
{
if (confirm("This confirms that you have acknowledged this" +
" message. Are you SURE you want to delete this message?")) {
alert("Your message will be deleted.");
document.form2.submit();
return true;
} else {
document.form2.reset();
return false;
}
}

function preventDelete()
{
for (i = 0; i < window.document.form1.racknowledge.length; i++)
{
if (window.document.form1.racknowledge[i].checked == true){
alert("OK to delete");
deleteMessage();
} else if (window.document.form1.racknowledge[i].checked == false){
alert("Blah Blah Blah");
return false;
}
}
}

Response.Write "<td align=center bordercolor=white bgcolor=lightblue><input type='radio' name=rdelete value="& RS2("WebMessageID") & " onclick=""preventDelete();""></td>"


Can someone please show me what I'm doing wrong? At this point I'd even settle for just being able to copy and past a script, but I looked at JavaScripts.com and some other places and couldn't find anything that does this.

Thanks in advance,
KP

fredmv
12-15-2003, 01:36 AM
Try this:<a href="#" onclick="if(confirm('Are you sure you want to delete this message?')) document.form2.submit();">Delete</a>