VAT없이 미리 계산 된 금액에서 VAT없이 금액을 계산하려고합니다. HTML 양식은 다음과 같습니다JavaScript의 div에서 값을 가져 오지 못했습니다.
<table>
<tr>
<th>Sl No</th>
<th>Description of goods</th>
<th>Price</th>
<th>VAT%</th>
<th>Price with VAT</th>
<th>Quantity</th>
<th>Amount</th>
</tr>
{foreach name = feach item = k from = $ip key = ind}
<tr>
<td>{$ind+1}</td>
<td>{$k->brand},{$k->model}</td>
<td id="prd_prc"> </td>
<td id="vat{$ind}">
<select name="vatpc" id="vatpc" onchange="calculate('{$ind}')">
<option value="5">5</option>
<option value="13.5">13.5</option>
</select>
</td>
<td id="total_cost{$ind}">{$k->price}</td>
<td>{$k->quantity}</td>
<td>{$k->total_cost}</td>
</tr>
{/foreach}
<tr>
<td> </td>
<td> </td>
<td> </td>
<td>Total Cost </td>
<td>{$final_amount}</td>
</tr>
</table>
그리고 자바 스크립트의 기능은 다음과 같습니다
function calculate(idno)
{
//alert(idno);
var vat_pc = document.getElementById("vatpc").value;
var total_cost = document.getElementById("total_cost"+idno).value;
//total_cost = Number(total_cost);
alert(total_cost);
//vat_pc = parseFloat(vat_pc);
// = v + 2.10 + 11.25;
//alert(v);
// document.getElementById("total").innerHTML = "Total - amount : "+v+" USD";
}
을하지만 경고가 undefined
을 보여줍니다. 나는 innerHTML
을 추가하려했지만 결과는 동일합니다. 도와주세요. 미리 감사드립니다.
'idno'에 대한 가치를 찾으려고하면, 거의 오지 않을 것입니다 ... – maxjackie
나는 그 ... 오는 것을 확인했습니다. – Nitish