javascript - Adding 1 to div onsubmit -
javascript - Adding 1 to div onsubmit -
i have form submit database using ajax, there div on page has database binding counts total number of records submit on page refresh. want onsubmit of form, should add together 1 binding in div counts total number of records submitted
<div id="count_div"></div> <form id="form2" name="form2" method="post" action="<%=mm_editaction%>"> <input name="comment" type="text" id="comment" size="50" /> <input name="imagefield3" type="image" id="imagefield3" src="imgs/buttons/comment.png" align="bottom" /> <input name="wardrobe" type="hidden" id="wardrobe" value="1" /> <input name="comme" type="hidden" id="comme" value="2" /> <input name="comfn" type="hidden" id="comfn" value="3" /> <input name="photo_id" type="hidden" id="photo_id" value="4" /> <input name="ctype" type="hidden" id="ctype" value="picture" /> <input name="resp_email" type="hidden" id="resp_email" value="4" /> <input type="hidden" name="mm_insert" value="form2" /> </form>
ajax
<script> $(document).ready(function(){ $("#form2").on('submit',function(event){ event.preventdefault(); info = $(this).serialize(); $.ajax({ type: "post", url: "int_p_cmt.asp", data: info }).success(function() { $("#msg_div").append("<div class='messages' style='border:1px violet solid; padding:2px; margin:5px;'>your comment has been saved </div>"); settimeout(function() { $(".messages").fadeout(function(){ $(".messages").remove(); }); }, 1000); $("input[type=text]").val(""); }); }); }); </script>
if understood correct: want increment th value of "count_div" div seek this:
$(document).ready(function(){ $("#form2").on('submit',function(event){ event.preventdefault(); info = $(this).serialize(); $.ajax({ type: "post", url: "int_p_cmt.asp", data: info }).success(function() { $("#msg_div").append("<div class='messages' style='border:1px violet solid; padding:2px; margin:5px;'>your comment has been saved </div>"); settimeout(function() { $(".messages").fadeout(function(){ $(".messages").remove(); }); }, 1000); $("#count_div").html(parsefloat($("#count_div").html())+1); $("input[type=text]").val(""); }); });
});
javascript jquery ajax
Comments
Post a Comment