Jump to content

Archived

This topic is now archived and is closed to further replies.

dptr1988

javascript <BUTTON> submits form when I don't want it to

Recommended Posts

I have a form and have a < BUTTON> with the 'onClick' event. When I click the button it clears a textarea in the form with this 'document.getElementById('daform').db_query.value=' ' ". My problem is that when I put the button inside of < FORM> tags it will submit the form after running the javascript. But when I have it out of the < FORM> tag it will just clear the text and not submit the form. Can I put the button in the < FORM> tag and still have it not submit the form? How?

Thanks

Share this post


Link to post
Share on other sites
try adding [code]return false;[/code] to the onClick

Share this post


Link to post
Share on other sites
You can also use
<input type="button" value="Clear" />

This won't submit the form.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.