Home » Php » javascript – The specified value "\t1750000" is not a valid number

javascript – The specified value "\t1750000" is not a valid number

Posted by: admin February 25, 2020 Leave a comment

Questions:

I got this error when choosing data from the selected form.
When total prices should have been selected, this should not appear.
I use the input type number, but when using the input type text, the total price appears.

I will write the code below

enter image description here

function hitungpaketaqiqahsatuan(){
    var id_paketaqiqah=$("#id_paketaqiqah").val();
    var layanan_paketaqiqah="Masak";
    var jumlah_paketaqiqah=$("#jumlah_paketaqiqah").val();

    $.ajax({
      type:'POST',
      url:'<?php echo base_url(); ?>ajax/hitungpaketaqiqahlagi/',     
      cache: false,
      data:{
        id_paketaqiqah: id_paketaqiqah,
        jumlah_paketaqiqah: jumlah_paketaqiqah
      },
      success:function(nilai){
        $('#total_pesanan_hewan').val(nilai);
      }
    }); 
    hitungtotaldansisa();
  }
  <div class="form-group">
            <label>Jumlah</label>
            <input onkeyup="hitungpaketaqiqahsatuan()" onchange="hitungpaketaqiqahsatuan()"  type="number" class="form-control" placeholder="Jumlah" name="jumlah_paketaqiqah" id="jumlah_paketaqiqah" min="1" value="1" required>
          </div>
           <div class="form-group">
            <label>Total</label>
            <input type="number" class="form-control" placeholder="Total" name="total_pesanan_hewan" id="total_pesanan_hewan" disabled required>
          </div>
public function hitungpaketaqiqahlagi()
{       
    if(!empty($this->cek))
    {
        $id_paketaqiqah = $this->input->post('id_paketaqiqah');
        $jumlahpaket = $this->input->post('jumlah_paketaqiqah');
        $paket_aqiqah = $this->pam->getSinglePaketaqiqah($id_paketaqiqah);

        foreach ($paket_aqiqah->result() as $pa) {
            $harga_paketaqiqah = $pa->harga_masak;

            $total = $jumlahpaket*$harga_paketaqiqah;                   

            echo $total;
        }
    }
}
How to&Answers: