I am working on ajax, the ajax function is working fine but the problem is to break ajax response between three div. Let me explain in detail.
1. I have a page where i have one select box and three input , and by the onchange
event i want the ajax value in input boxes.
for further explaination here is my code(Ajax Response):
<?php
include("include/config.php");
$enrol=$_GET['q'];
$query=mysqli_query($con,"select * from dbo_tbmembermaster where vc_enrol_no='$enrol'");
$result=mysqli_fetch_assoc($query);
$mem_id=$result['nu_member_id'];
$result['nu_member_id'];
$query2=mysqli_query($con,"select SUM(nu_amount) as amt_sub from dbo_tbmemberdues where nu_member_id='$mem_id' and vc_due_for='Subscription'");
$result2=mysqli_fetch_assoc($query2);
echo '<div id="d1">';
echo $amt_sub=$result2['amt_sub'];
echo '</div>';
$query3=mysqli_query($con,"select SUM(nu_amount) as amt_fund from dbo_tbmemberdues where nu_member_id='$mem_id' and vc_due_for='Employees Welfare Fund'");
$result3=mysqli_fetch_assoc($query3);
echo '<div id="d2">';
echo $amt_fund=$result3['amt_fund'];
echo '</div>';
$query4=mysqli_query($con,"select SUM(nu_amount) as amt_fund from dbo_tbmemberdues where nu_member_id='$mem_id' and vc_due_for='Cause List'");
$result4=mysqli_fetch_assoc($query4);
echo '<div id="d3">';
echo $amount=$result4['amt_fund'];
echo '</div>';
?>
Now this is my response and please note here i have some values in three different div <div id="d1">,<div id="d2">,<div id="d3">
2. Now Iam getting this response on my page by the Id <div id="result"></div>
. So After Ajax call I have d1,d2,d3 on my page and the value of these div I am trying to get into three input box. I am doing this by javascript as:
function showdues()
{
var aa=document.getElementById("d1").innerHTML;
//alert("vhsgfhsg");
document.getElementById("sub_due").value=aa;
}
and I am calling ajax function and this function by onchange
like this <select name="dues" onchange="Javascript: showUser(dues.value);showdues();">
, but ajax function is working but this not working and I am not getting anything into input box.
It may be a weird idea to do this but I uses my best and your any type of idea , what I am missing and what should I have to do.. If there is any better idea Plz Let me know....
thanks in advance.
It's not entirely clear what the problem is, but there are two ways you can go:
(you could also use a combination of the two of course).
And you have an sql injection problem.
The simplest way would be
Get the values in a javascript variable and split them depending upon the comma [ , ]. It will give you 3 different arrays.
Now place each of the array values accordingly in the input box you want.
Hope it gives you some idea
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.