Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

with two java script functions

Status
Not open for further replies.

daka94

Programmer
Apr 27, 2001
33
US
Hai here i want to get confirm message before delte.here i wrote two java script functions .but it is not working.it is deleting directly without asking confirmation.confirm Action function is not working.
please help me.
<html>
<head>
<title>hello</title>
<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
function confirmAction(){
return confirm(&quot;Do you want to delete ?&quot;)
}
function submitForm(location) {
document.form1.action = location;
document.form1.submit();
}
</SCRIPT>
</head>

<body bgcolor=&quot;#F0FEFF&quot;>

<form action=&quot;&quot; name=&quot;form1&quot; id=&quot;form1&quot; method=&quot;post&quot; onSubmit=&quot;return confirmAction()&quot;>
............
........
............
..........
</form>
<a href=&quot;javascript:submitForm('Delete.jsp')&quot;><img
src=&quot;delete.gif&quot; BORDER=&quot;0&quot; ALT=&quot;Delete&quot;
WIDTH=&quot;100&quot; HEIGHT=&quot;32&quot;></a>
</body>
</html>
thank u
 
is it when you click the link that the object is deleted, cause when you click the link the submitForm(..) function is called... try instead:
Code:
function submitForm(location) {
 if(confirm(&quot;Do you want to delete ?&quot;))
 {
  document.form1.action = location;
  document.form1.submit();
 }
or something like that My codes look like something a kid wrote
I have absolutely no idea what I am talking about
Somehow I still manage to make it work
 
hi daka94, 801119 is correct: when u submit ur form just like this: form.submit() then it wont run onsubmit event handler.. i tryed ie5.0 & nc4.61..
use 801119's suggestion Victor
 
Try adding an onClick event to the link:

Code:
<a href=&quot;javascript:submitForm('Delete.jsp')&quot;><img
        src=&quot;delete.gif&quot; BORDER=&quot;0&quot; ALT=&quot;Delete&quot;
        WIDTH=&quot;100&quot; HEIGHT=&quot;32&quot; onClick=&quot;return confirmAction()&quot;></a>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top