Koha/koha-tmpl/intranet-tmpl/prog/en/js/additem.js
Owen Leonard 755b509cd6 Steamlining javascript for cloning additem block and tweaking style.
Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
2008-10-22 16:30:48 -05:00

32 lines
No EOL
1 KiB
JavaScript

function check_additem() {
var barcodes = document.getElementsByName('barcode');
var success = true;
for(i=0;i<barcodes.length;i++){
for(j=0;j<barcodes.length;j++){
if( (i > j) && (barcodes[i].value == barcodes[j].value) && barcodes[i].value !='') {
barcodes[i].className='error';
barcodes[j].className='error';
success = false;
}
}
}
// TODO : Add AJAX function to test against barcodes already in the database, not just
// duplicates within the form.
return success;
}
$(document).ready(function(){
$(".cloneItemBlock").click(function(){
$(this).parent().parent().clone(true).insertAfter($(this).parent().parent()).find("a.deleteItemBlock").show();
var quantityrec = parseFloat($("#quantityrec").attr("value"));
quantityrec++;
$("#quantityrec").attr("value",quantityrec);
return false;
});
$(".deleteItemBlock").click(function(){
$(this).parent().parent().remove();
var quantityrec = parseFloat($("#quantityrec").attr("value"));
quantityrec--;
$("#quantityrec").attr("value",quantityrec);
return false;
});
});