以下のようなJavaScript関数があります。
function calculateBill(id,price)
{
var qty = document.getElementById('qty_'+id).value;
var cur_value =qty*price;
var frm_lngth = document.getElementById('bnfsendgoods').length;
var fld_length1 = Number(frm_lngth) - 10;
var counter = document.getElementById('cntr').value;
var fld_length = (Number(fld_length1)) / (Number(counter));
fld_length = Number(fld_length);
var temp_total = 0;
alert(fld_length);
for(var i = 1; i<=fld_length; i++)
{
if( i != id )
{
alert('qty_'+i); //line 301,alerts only qty_1
var temp_q = document.getElementById('qty_'+i).value;
var temp_p = document.getElementById('ret_price_'+i).value; //Line 308
var temp_total1 = temp_q*temp_p;
temp_total = Number(temp_total) + Number(temp_total1);
}
}
var final_total = Number(cur_value) + Number(temp_total);
document.getElementById('total').value = final_total;
}
行301では、alert(fld_length);
アラート8.id = 3
私の論理によれば、、、、、などのようqty_1
に警告する必要があります。ただし、アラートのみ です。どうしたの?qty_2
qty_4
qty_5
qty_6
qty_1