javascript - How do I show the message of the input box after submitting my form? -
i building form. , wish keep input value visible after submitting form. followed instructions online use showmessage() function, however, it's not working me.
<form id = "form1" action="." method="post">{% csrf_token %} <div class=".col1" style="float:left;vertical-align: middle;"> {{ form.region }} {{ form.operator }} </div> <div id = "form1_value" class="col-xs-2 style="vertical-align: middle;"> {{ form.value }} </div> </form> <div> <input type="button" class = "btn" value="run" onclick="submitform1(), showmessage()"/> </div>
your onclick
function should read submitform1()
, should make ajax request, greatly simplified using jquery:
$.ajax({ method: "post", url: ".", // action attribute of <form> data: { key1: value1, key2: value2 }, success: function(data, textstatus, jqxhr) { // event handler when submission complete } }
code adapted here.
this not reload page or load new page. might want set disabled = true
attribute of <input type="button"...
on button prevent re-clicking form submit button.
edit: note answer being written before op noted django project's backend, left here in hopes benefits asking similar question in future.
Comments
Post a Comment