I am trying to submit a form using button click result_submit
event. Here I am using type as button
instead of submit
.
Reason for changing button type from submit to button: I was trying to show some hidden div after the form submit, but I couldn't achieve that using a submit function. when I changed it type=button, I was able to do it with onclick function.
The problem I am facing here is I am not getting any results now.As soon as I change button type back to submit
, it will work. Any suggestions here to resolve this ?
form html:
<form method="post" id="form_result" action="">
<----some options to select here->
<div class="form-group">
<button onclick="show_result()" type="button" name="result_submit" id="result_submit" style="display: none;margin:1%;" >Submit</button>
</div>
</form>
Jquery:
function show_result() {
document.getElementById('form_result').submit();
}
Php (file name : functions.php):
if(isset($_POST['result_submit'])){
include_once 'dbConnection.php';
<--some codes here----->
if ($_POST['result_options'] == 'Current_Month'){
<---some codes here----->
}
}
Important Note:-
my PHP codes are on default WordPress functions.php
file. I added action for form, but not working.
Also tried to move the PHP code from functions.php
to a new file. that is also not working. I think there is something wrong with my other codes.