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 Link to comment https://forums.phpfreaks.com/topic/12579-javascript-submits-form-when-i-dont-want-it-to/ 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 Link to comment https://forums.phpfreaks.com/topic/12579-javascript-submits-form-when-i-dont-want-it-to/#findComment-48207 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 Link to comment https://forums.phpfreaks.com/topic/12579-javascript-submits-form-when-i-dont-want-it-to/#findComment-48209 Share on other sites More sharing options...
cmgmyr Posted June 21, 2006 Share Posted June 21, 2006 Awesome No problem! Link to comment https://forums.phpfreaks.com/topic/12579-javascript-submits-form-when-i-dont-want-it-to/#findComment-48210 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. Link to comment https://forums.phpfreaks.com/topic/12579-javascript-submits-form-when-i-dont-want-it-to/#findComment-48220 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.