/    Sign up×
Community /Pin to ProfileBookmark

Proper Way to Not Have a Form Submit?

When I have a form and click the button in the form, if I don’t want it to submit, what is the proper way to do that?

Right now I do this:

[code]
<form name=’frmName’ method=’post’ action=’test.html’ onSubmit=’return false;’>
[/code]

Is there a different way to do this? In IE it seems to work, but in firefox, it hangs forever.

************ON EDIT***********
i think I found out what it is….

its not the form or the onsubmit…..its the fact that I put a document.write in the <head><script></script></head>

right when I put this in, it hangs…..

[code]
<head>
<script>
function test(){
document.getElementById(‘settings’).style.display=’none’;
document.write(“<div>test<br>test<br>test</div>”);
}
</script>
</head>
[/code]

Can you not put a document.write in a function in the script tags?
Does firefox not use document.write?

************ON EDIT***************

I figured it out…..I had to replace the document.writes with document.getElementById(‘name’).innerHTML

is it possible to delete this post?

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@KorMay 31.2011 —  but in firefox, it hangs forever.[/QUOTE]
How's that? All the browsers do the same following that code: they prevent the submit action. There is no "hang forever" neither in Firefox nor in any other browser (unless, of course, JavaScript is disabled). What do you mean by "hang forever", anyway?
×

Success!

Help @chunter 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.18,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

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