[thelist] please help with this code

Gary McPherson lists at ingenyus.net
Tue Dec 30 01:27:01 CST 2003

Zhang, Lingling wrote:

>It says there's a syntax error with this code:
><script language="JavaScript">
>function checkIndividualDelete(entry, button)
>    if (confirm("Are you sure you want to delete this individual record?"))
>            entry.deleteIndividual.value = 1;
>            entry.deleteIndividualID.value = button.value;
>            alert("delete:"+form.deleteIndividual.value+"
>        response.redirect("dbentry2.asp");
>    else {
>        button.checked = false;
>    }
><form name="entry" ...>
><input type=radio ... onclick=" checkIndividualDelete(entry, this)">
><input type=hidden name="deleteIndividual" value=0>
><input type=hidden name="deleteIndividualID" value="">
>Could someone please tell me what's wrong with this code?
>Thanks a lot.
Firstly, you're missing the braces around your if block.

Secondly, you're calling Response.Redirect inside client-side 
Javascript, which is never going to work. You could replace that line 
with "entry.submit();" (assuming that dbentry2.asp is the page 
processing your form results and you've set the action of the form to 
the correct page) but the average user wouldn't expect the form to be 
submitted after clicking a radio button, so it's probably best if you 
remove that line altogether and allow the user to submit the form 
manually. To further improve the process, you could move the script call 
to the onsubmit event for the form - that way, only one confirmation is 
required if the user makes a mistake while selecting the deletion option 
or changes their mind.

Hope that helps,


 From your code snippet, it would seem you are presenting a list of 
options for deletion - unless you have some specific reason

More information about the thelist mailing list