[thelist] please help with this code
Zhang, Lingling
lingz at cs.umd.edu
Tue Dec 30 10:58:51 CST 2003
Thanks for all who responded to me!
Now I fixed the problems you pointed out, and the syntax error is gone. However,
when I clicked OK on the confirm dialog, the code inside the if block didn't get
executed. Any idea why this is happening?
Thanks,
ll
-----Original Message-----
From: Gary McPherson [mailto:lists at ingenyus.net]
Sent: Tuesday, December 30, 2003 2:27 AM
To: thelist at lists.evolt.org
Subject: Re: [thelist] please help with this code
Zhang, Lingling wrote:
>Hi,
>
>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+"
>"+entry.deleteIndividualID.value);
> response.redirect("dbentry2.asp");
> else {
> button.checked = false;
> }
>}
></script>
>
><form name="entry" ...>
>...
><input type=radio ... onclick=" checkIndividualDelete(entry, this)">
>...
><input type=hidden name="deleteIndividual" value=0>
><input type=hidden name="deleteIndividualID" value="">
>
></FORM>
>
>Could someone please tell me what's wrong with this code?
>
>Thanks a lot.
>LL
>
>
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,
Gary
From your code snippet, it would seem you are presenting a list of
options for deletion - unless you have some specific reason
--
* * Please support the community that supports you. * *
http://evolt.org/help_support_evolt/
For unsubscribe and other options, including the Tip Harvester
and archives of thelist go to: http://lists.evolt.org
Workers of the Web, evolt !
More information about the thelist
mailing list