Koha/koha-tmpl/intranet-tmpl/prog/en/js/additem.js
Ryan Higgins b2f5cf3ad2 Further updates to acq, merging in dev_week mods.
Splitting orders now on receipt.
Many tmpl updates to pass correct values btwn scripts.

Signed-off-by: Joshua Ferraro <jmf@liblime.com>
2008-01-01 15:07:08 -06:00

37 lines
1.6 KiB
JavaScript

function countItemBlocks() {
var outeritemblock = document.getElementById('outeritemblock');
var quantityrec = document.getElementById('quantityrec');
var origquantityrec = document.getElementById('origquantityrec');
var itemblockcount = outeritemblock.getElementsByTagName('div');
var num = parseFloat(origquantityrec.value) + itemblockcount.length;
quantityrec.setAttribute('value',num);
}
function deleteItemBlock(index) {
var aDiv = document.getElementById(index);
aDiv.parentNode.removeChild(aDiv);
countItemBlocks();
}
function cloneItemBlock(index) {
var original = document.getElementById(index); //original <div>
var clone = original.cloneNode(true);
// set the attribute for the new 'div' subfields
clone.setAttribute('id',index + index);//set another id.
var NumTabIndex;
NumTabIndex = parseInt(original.getAttribute('tabindex'));
if(isNaN(NumTabIndex)) NumTabIndex = 0;
clone.setAttribute('tabindex',NumTabIndex+1);
var CloneButtonPlus;
var CloneButtonMinus;
// try{
CloneButtonPlus = clone.getElementsByTagName('a')[0];
CloneButtonPlus.setAttribute('onclick',"cloneItemBlock('" + index + index + "')");
CloneButtonMinus = clone.getElementsByTagName('a')[1];
CloneButtonMinus.setAttribute('onclick',"deleteItemBlock('" + index + index + "')");
CloneButtonMinus.setAttribute('style',"display:inline");
// }
//catch(e){ // do nothig if ButtonPlus & CloneButtonPlus don't exist.
//}
// insert this line on the page
original.parentNode.insertBefore(clone,original.nextSibling);
countItemBlocks();
}