0
기능에 문제가 있습니다. 실제로 일부 텍스트 필드에서 계산을 수행하려면이 함수를 만들어야합니다. 한 줄로 작업했을 때 아무런 문제가 없었습니다. 하지만 최근에 누군가가 여러 행 (하나의 행을 동적으로 추가 할 수있는 테이블)을 만들도록 요청 했으므로 다음 함수를 사용하여 행을 중복시킬 수는 없지만 ID는 관련된 모든 필드를 변경하므로이 필드에 클래스를 추가합니다 . 다음과 같이 그러므로 나는 진행 :계산을위한 자바 스크립트 기능
ID로function calcdebours() {
var taux = document.getElementById('debours_taux_tva').value;
var ht_no_tva = document.getElementById('debours_montant_ht_no_tva').value;
var ht_tva = document.getElementById('debours_montant_ht_tva').value;
var tva = Math.round((((ht_tva) * (taux))/100) * 100)/100;;
if (taux == '') {
taux = 0;
}
if (ht_no_tva == '') {
ht_no_tva = 0;
}
if (ht_tva == '') {
ht_tva = 0;
}
document.getElementById('debours_montant_tva').value = tva;
document.getElementById('debours_montant_ttc').value = (tva) + parseFloat(ht_tva) + parseFloat(ht_no_tva)
}
function
montant_debours() {
var ttc = document.getElementById('debours_montant_ttc').value;
var ttc2 = document.getElementById('debours_montant_ttc2').value;
if (ttc == '') {
var ttc = 0;
} else {
var ttc = document.getElementById('debours_montant_ttc').value;
}
if (ttc2 == '') {
var ttc2 = 0;
} else {
var ttc2 = document.getElementById('debours_montant_ttc2').value;
}
tx = parseFloat(ttc) + parseFloat(ttc2);
document.getElementById('ttc_cheque').value = Math.round(tx * 100)/100;
}
이 동일하지, 내가 많은 사람을 만들 필요가 수행
function clone(line) {
newLine = line.cloneNode(true);
line.parentNode.appendChild(newLine);
var tab = document.getElementsByClassName('libelle_debours')
var i = -1;
while (tab[++i]) {
tab[i].setAttribute("id", "_" + i);
};
var cab = document.getElementsByClassName('ht_no_tva')
var j = -1;
while (cab[++j]) {
cab[j].setAttribute("id", "_" + j);
};
var dab = document.getElementsByClassName('ht_tva')
var k = -1;
while (dab[++k]) {
dab[k].setAttribute("id", "_" + k);
};
var eab = document.getElementsByClassName('taux')
var l = -1;
while (eab[++l]) {
eab[l].setAttribute("id", "_" + l);
};
var fab = document.getElementsByClassName('tva')
var m = -1;
while (fab[++m]) {
fab[m].setAttribute("id", "_" + m);
};
}
function delRow() {
var current = window.event.srcElement;
//here we will delete the line
while ((current = current.parentElement) && current.tagName != "TR");
current.parentElement.removeChild(current);
}
사실 문제는 계산을하는 데 사용되는 두 번째 함수는
함수 줄이 있습니까?하나의 함수를 사용하여 각 행을 처리 할 수 있습니까?
그렇다면 어떻게 말해 줄 수 있습니까?
jquery를 사용하지 않는 이유는 무엇입니까? – Mateusz
내가 정말 사용하려고했기 때문에 나처럼 두뇌가 너무 복잡하다. –
그래, jQuery 없이는 쉬운 방법을 알지 못하지만 나중에 jQuery와 설명을 함께 게시 할 것이다. – Mateusz