How I get total amount in ajax success function

Viewed 50

NOTE: I want to receive values from both ids of the dropdown. I am getting values of registration and license fees using nature id but we have to make a calculation using permit id with values of registration and license fees. Both values of registration and license fees are getting in success except amount (permit id)

I have sent two ids of different dropdown using ajax

$('#nature_f').on('change', function(){
          var natureID = $(this).val(); 
          var permitID = $('#establishment_f').val(); 
          ///console.log(natureID);       
          // if(natureID){
          $.ajax({
                  type:'POST',
                  url:"method.php",
                  data: {nature_id: natureID, permit_id: permitID},
                  // data:'nature_id='+natureID,
              success:function(value){
              var data = value.split(",");
            $('#registration').val(data[0]);
            $('#license').val(data[1]); 
            $('#amount').val(data[2]); 
                        
            //$('#amount').val(a+b);               ``    
              }
          }); 
      // }else{
          $("#registration").val("Select Health Trade Name first"); 
          $("#license").val("Select Health Trade Name first"); 
      // }
  });
</script>

Method is defined to fetch respective values using nature id

 if(isset($_POST["nature_id"])){ 
  // Fetch city data based on the specific state 
    // print_r($_POST);
    // die();
    $data3= $_POST["permit_id"];
$fees = mysqli_query($conn, "SELECT * FROM licensefees WHERE Health_TradeId = '". $_POST['nature_id'] . "'");
  
  // Generate HTML of city options list 
  if($fees->num_rows > 0){ 
    while($feerow = $fees->fetch_assoc()) {

 $data1= $feerow['Registration_Fee'];
 $data2= $feerow['License_Fee_PerDay'];
          
    } 
    }
    else {
    echo "No records Found";
    }
    
echo $data1.",".$data2.",".$data3;
    die; 
    } 
  

In view registration fees, license fees are ok but the amount which is total of both is not okay. I am not able to make a total of both

<input type="text"  id="registration"  placeholder="Select Health Trade Name  First" class="form-control" readonly=""><br> <br>
        <input type="text" id="license" placeholder="Select Health Trade Name First" class="form-control" readonly=""> 

<input type="text" name="amount" id="amount" placeholder="Select Health Trade Name & License Validity First" value="" class="form-control" readonly="">
0 Answers
Related