javascript - form not getting submitted on button click -
i trying submit form on button click want user confirm whether sure or not. have mutiple submit button on form , want pop-up in case of delete. when make type of button submit. form gets submitted twice if confirm else gets submitted once (i don't want submitted in case).
i have multiple form on page. that's why trying submit form getting parent node , not using getelementbyid.
javascript function
function deleteevent(btn){ var confirmed=confirm('do want delete event?'); if(confirmed){ var f = btn.parentnode; f.submit(); } else{ return false; } }
html code
<form action="#" method="post"> <input type="button" name="delete" value="delete" onclick ="deleteevent(this)"> </form>
thanks.
working solution:
<input type="submit" name="delete" value="delete" onclick ="return confirm('do want delete event?');">
try this
use onclick="return deleteevent(this);" if button type submit
<input type="submit" name="delete" value="delete" onclick="return deleteevent(this);">
Comments
Post a Comment