如何使用javascript从html中的增值和动态表单中的增值中找到总价值?

如何使用javascript从html中的增值和动态表单中的增值中找到总价值?,javascript,php,jquery,html,Javascript,Php,Jquery,Html,我很难找到潘华兰的总价值。 我在这里使用动态形式。我想将所有total的值以动态形式与biayalainlain的值相加。我认为问题在于var ttl2=document.getElementById(totalid).value;如何在additem()中获取id以放入prosestotal()? 这是我的html和javascript代码: 函数和(){ var hrg=document.getElementById('harga').value; var jml=document.get

我很难找到潘华兰的总价值。 我在这里使用动态形式。我想将所有total的值以动态形式与biayalainlain的值相加。我认为问题在于var ttl2=document.getElementById(totalid).value;如何在additem()中获取id以放入prosestotal()? 这是我的html和javascript代码:

函数和(){
var hrg=document.getElementById('harga').value;
var jml=document.getElementById('jumlah').value;
var结果=parseInt(hrg)*parseInt(jml);
如果(!isNaN(结果)){
document.getElementById('total')。值=结果;
}
}
函数additem(){
//menentukan目标附加
var itemlist=document.getElementById('itemlist');
//membuat元件
var行=document.createElement('tr');
var nama=document.createElement('td');
var kode=document.createElement('td');
var harga=document.createElement('td');
var jumlah=document.createElement('td');
var total=document.createElement('td');
var aksi=document.createElement('td');
//孟附加元素
itemlist.appendChild(行);
世界银行(nama);
第2行,附属儿童(科德);
世界其他地区(哈尔加);
世界其他地区(朱姆拉);
行。追加子行(总计);
第二行,附属儿童(aksi);
//membuat元素输入1
var nama_input=document.createElement('input');
/*nama_input.setAttribute('id','nama')*/
nama_input.setAttribute('name','nama_input[]);
nama_input.setAttribute('class','form control');
var kode_input=document.createElement('input');
/*kode_input.setAttribute('id','kode1')*/
setAttribute('name','kode_input[]);
kode_input.setAttribute('readonly','');
kode_input.setAttribute('class','form control');
var harga_input=document.createElement('input');
harga_input.setAttribute('type','number');
setAttribute('name','harga_input[]);
harga_input.setAttribute('class','harga form control');
/*harga_input.setAttribute('onkeyup','sum();')*/
var jumlah_input=document.createElement('input');
jumlah_input.setAttribute('type','number');
setAttribute('name','jumlah_input[]);
jumlah_input.setAttribute('class','jumlah form control');
jumlah_input.setAttribute('autocomplete','off');
/*jumlah_input.setAttribute('onkeyup','sum();')*/
var total_input=document.createElement('input');
total_input.setAttribute('name','total_input[]);
total_input.setAttribute('class','total form control');
total_input.setAttribute('readonly','');
var hapus=document.createElement('span');
//元素输入法
nama.appendChild(nama_输入);
kode.appendChild(kode_输入);
harga.appendChild(harga_输入);
jumlah.appendChild(jumlah_输入);
总计。追加子项(总输入);
阿卡西·阿佩奇尔德(hapus);
hapus.innerHTML='hapus';
//membuat-aksi删除元素
hapus.onclick=函数(){
row.parentNode.removeChild(row);
};
var namaid='nama'+(Math.floor((1+Math.random())*0x10000));
var kodeid='kode'+(Math.floor((1+Math.random())*0x10000));
var hargaid='harga'+(Math.floor((1+Math.random())*0x10000));
var jumlahid='jumlah'+(Math.floor((1+Math.random())*0x10000));
var totalid='total'+(Math.floor((1+Math.random())*0x10000));
nama_input.setAttribute('id',namaid);
kode_input.setAttribute('id',kodeid);
harga_input.setAttribute('id',hargaid);
jumlah_input.setAttribute('id',jumlahid);
total_input.setAttribute('id',totalid);
$(jumlah_输入).on('keyup',function(){
金额(哈格德、朱姆拉希德、totalid)
})
$(harga_输入).on('keyup',function(){
金额(哈格德、朱姆拉希德、totalid)
})
$(总输入)。on('keyup',function(){
散文集(totalid、total、biayalain)
})
函数和(hargaid、jumlahid、totalid){
var hrg=document.getElementById(hargaid).value;
var jml=document.getElementById(jumlahid).value;
var结果=parseInt(hrg)*parseInt(jml);
如果(!isNaN(结果)){
document.getElementById(totalid).value=结果;
}
}
$(“#”+namaid).自动完成({
来源:“get_barang.php”,
最小长度:2,
选择:功能(事件、用户界面){
$(“#”+kodeid.val(ui.item.kode);
$(“#”+hargaid).val(ui.item.harga);
}
});
}
函数prosestotal(){
var ttl=document.getElementById('total')。值;
var ttl2=document.getElementById(totalid).value;
var biayalain=document.getElementById('biayalain').value;
var hsl=parseInt(ttl)+parseInt(ttl2)+parseInt(biayalain);
如果(!isNaN(hsl)){
document.getElementById('total_penjualan')。value=hsl;
}
}

纳米
科德
哈尔加
朱姆拉
全部的
坦巴
比亚莱恩:
彭华兰合计: