This is the Index.php file
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
<script src="submit.js"></script>
<div class="container-fluid">
<div class="row" id="formsett">
<div class="col-sm-4">
<div id="div1">
</div>
</div>
<div class="col-sm-4">
<div id="idform">
<form id="idform" method="POST">
<p>
<label> <b> Enter NIC No: </b> </label> <br/>
<input type="text" id="idno" name="idno" />
</p>
<p>
<input type="button" id="btn" onclick="SubmitFormData();" value="Submit" />
</p>
</form>
</div>
</div>
<div class="col-sm-4">
<div id="div2">
</div>
</div>
</div>
</div>
This is the Submit.php file
$idno = ($_POST['idno']);
$gen='';
$img='';
if($idno>=12345){
$gen="ABC";
$img="<img src= 'abc.jpg'>";
}else{
$gen="DEF";
$img="<img src= 'def.jpg'>";
}
echo "$img";
echo "$gen";
This is the Submit.js file
function SubmitFormData() {
var idno = $("#idno").val();
$.post("submit.php", { idno: idno },
function(data) {
$('#div1').html(data);
});
}
I want to see the $gen value in Div1 and $img value in Div2 when click on the button without refreshing the Index.php page.
Now, using this Js code, I can see both $gen and $img values in a same div. I tried so many times by changing this js code and submit.php code, but didn't work.
How can divide that two values into two divs?