/    Sign up×
Community /Pin to ProfileBookmark

javascript confirm before submission of form

i don’t even know if this is possible:

i have text, the word “Delete” as a form. i want to confirm before submission.

i want to click, confirm, then submit. the “onsubmit” attribute of the form is being completely ignored.

form code:

[CODE]<form action=”admin.php” method=”post” name=”bdel3″ onsubmit=”return confdelete()”>
<a href=”admin.php” onclick=”document.bdel3.submit(); return false”>Delete</a></form>[/CODE]

javascript function:

[CODE]function confdelete() {
var answer = confirm(“delete?”)
if (answer) return true;
else return false
}[/CODE]

needless to say i’m no JS expert ^^

[I]any ideas gratefully received ?[/I]

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@DokSep 09.2008 — Replace the link with an actual submit button. Calling the submit method of a form element does not trigger the onsubmit event.
Copy linkTweet thisAlerts:
@hitecbillauthorSep 09.2008 — Replace the link with an actual submit button. Calling the submit method of a form element does not trigger the onsubmit event.[/QUOTE]
lovely, works a treat..spot on m8.

[B]thx for your help Dok ?[/B]



just out of a pedantic interest, would it be possible to create a rollover for the submission button? (i doubt it)

i.e. just to spoof the underline rollover of text?

it's only for a non-public facing content admin page of a client site, so it's not important but was jus' wonderin'?


just as an after question, on adding this image i get these two new [U][/U]values in my post array?!

[edit_x] => 26
[edit_y] => 2


[I]wtf?![/I]
Copy linkTweet thisAlerts:
@DokSep 09.2008 — i.e. just to spoof the underline rollover of text?[/QUOTE]
I don't understand what you mean.
Copy linkTweet thisAlerts:
@hitecbillauthorSep 09.2008 — I don't understand what you mean.[/QUOTE]
you know, the underline onmouseover hover of a text link...?

i've made small gif's out of the text, so it [I]looks[/I] like a text link..

it's not important, just wondering if there was a way of doing it..?
×

Success!

Help @hitecbill spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...