/    Sign up×
Community /Pin to ProfileBookmark

Javascript not submitting my form

This was supposed to be incredibly quick and simple. To prevent the administrator of the website from accidentally deleting content from the site, I made a pop up confirmation box that asks the user if they are sure they want to continue. Below is the code:

*Bunch of HTML and PHP*

<script language=”JavaScript” type=”text/JavaScript”>
<!–
function confirmation() {
var select = confirm(“Are you sure you want to delete this?”);
if (select == true){
document.delete1.submit();
}
}
//–>
</script>

*Bunch more code*

<form name=”delete1″ action=”test.html”>
[INDENT][/INDENT]<input type=”hidden” name=”del” value=”<?=$edit_id?>” />
[INDENT][/INDENT]<a href =”#” onclick=”confirmation()”>Delete</a>
</form>

Mozilla does nothing when the OK button is hit, while IE is telling me the object ‘delete1’ is null. Help is much appreciated.

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@Marcel_DauthorJun 09.2010 — Good grief, I'd edit that code I posted to make it nicer but I see that's impossible. How can a site like this not have an edit button?
Copy linkTweet thisAlerts:
@SparoHawkJun 09.2010 — Try:

[CODE]document.forms['delete1'].submit();[/CODE]
Copy linkTweet thisAlerts:
@Shanu_chaudharyJun 09.2010 — Try this.. (no javascript function)

[code=html]<form name="delete1" action="test.html" method="post"> <a href ="test.html?edit_id ='<?=$edit_id?>'" onclick="javascript:return confirm('Are you sure you want to delete?')">Delete</a></form>[/code]

and then get the edit id from the url and run your sql query for delete.

Hope this helps...
Copy linkTweet thisAlerts:
@Marcel_DauthorJun 10.2010 — Try this.. (no javascript function)

[code=html]<form name="delete1" action="test.html" method="post"> <a href ="test.html?edit_id ='<?=$edit_id?>'" onclick="javascript:return confirm('Are you sure you want to delete?')">Delete</a></form>[/code]

and then get the edit id from the url and run your sql query for delete.

Hope this helps...[/QUOTE]


Wow it worked. Thanks a lot ?.
Copy linkTweet thisAlerts:
@Shanu_chaudharyJun 10.2010 — Wow it worked. Thanks a lot ?.[/QUOTE]

Good.... ?
×

Success!

Help @Marcel_D 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 6.16,
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: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

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