dptr1988 Posted June 21, 2006 Share Posted June 21, 2006 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 Quote Link to comment Share on other sites More sharing options...
cmgmyr Posted June 21, 2006 Share Posted June 21, 2006 try adding [code]return false;[/code] to the onClick Quote Link to comment Share on other sites More sharing options...
dptr1988 Posted June 21, 2006 Author Share Posted June 21, 2006 Hey thanks. I was returning 0 instead of 'false'. It works now Quote Link to comment Share on other sites More sharing options...
cmgmyr Posted June 21, 2006 Share Posted June 21, 2006 Awesome No problem! Quote Link to comment Share on other sites More sharing options...
nogray Posted June 21, 2006 Share Posted June 21, 2006 You can also use<input type="button" value="Clear" />This won't submit the form. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.