Hi,
I am trying to write a javascript which adds row/clone row on fly to a webform which opens in a modal box and add up values of COst Price field.
If I do this without modal box it works fine but within modal box its doesn't works.:mad:
Please help!!!
Code:
<script type="text/javascript">
var clone;
function cloneRow(){
var rows=document.getElementById('mytab').getElementsByTagName('tr');
var index=rows.length;
clone=rows[index-1].cloneNode(true);
var inputs=clone.getElementsByTagName('input'), inp, i=0,n ;
while(inp=inputs[i++]){
inp.name=inp.name.replace(/\d/g,'')+(index+1);
}
}
function addRow(){
var tbo=document.getElementById('mytab').getElementsByTagName('tbody')[0];
tbo.appendChild(clone);
cloneRow();
}
function addValue(obj){
obj.value=obj.value.replace(/[^\d]/,'');
var fields=document.getElementsByTagName('input'), i=0, tot=0, f;
while(f=fields[i++]){
f.name&&f.name.match(/cost/)?tot+=Number(f.value):null;
}
document.getElementsByName('sum')[0].value=tot;
}
onload=cloneRow;
</script>