I have a form, and when that form is submitted it sends an http post request to a php script which then perform the required calculations and echoes the result.
and currently I am just using a static content which shows that an action has been performed and its always the same string , now i am looking for a way to show the result that server echoes on the front end.
here is my current code :
Form Code:
<iframe name="dummyframe" id="dummyframe" style="display: none;"></iframe>
<form action="calculate.php" method="post" target="dummyframe">
<div class="form-group">......................................
..............................................................</div>
<div class="form-group">
<input type="text" name="Lstring" class="form-control" id="Lstring">
<input onclick="assd()" type="submit" class="btnDoAction" value="Add" />
<p id="sses"></p>
</div>
I know if I don't use the dummy frame as target on form submit I can show the echo result either in the same tab or in a new one , but I actually want the response right below the submit button as text , where it's showing a static string at the moment .
and this is my JavaScript to show the message right below the Submit button:
<script>
function assd() {
document.getElementById("sses").innerHTML = "Added!";
setTimeout(function(){ document.getElementById('usersframe').contentWindow.location.reload(); }, 2000);
setTimeout(function() {
document.getElementById("sses").innerHTML = " "
}, 2000)
}
</script>
As you can see that it always shows the same word everytime the button was pressed so I was just wondering how to go about showing the response by the server below the Button where its currently showing the static string ?