1 function check_additem() {
2 var barcodes = document.getElementsByName('barcode');
4 for(i=0;i<barcodes.length;i++){
5 for(j=0;j<barcodes.length;j++){
6 if( (i > j) && (barcodes[i].value == barcodes[j].value) && barcodes[i].value !='') {
7 barcodes[i].className='error';
8 barcodes[j].className='error';
13 // TODO : Add AJAX function to test against barcodes already in the database, not just
14 // duplicates within the form.
17 $(document).ready(function(){
18 $(".cloneItemBlock").click(function(){
19 var clonedRow = $(this).parent().parent().clone(true);
20 clonedRow.insertAfter($(this).parent().parent()).find("a.deleteItemBlock").show();
21 // find ID of cloned row so we can increment it for the clone
22 var count = $("input[id^=volinf]",clonedRow).attr("id");
23 var current = Number(count.replace("volinf",""));
24 var increment = current + 1;
26 var inputs = ["volinf","barcode"];
27 jQuery.each(inputs,function() {
28 // increment IDs of labels and inputs in the clone
29 $("label[for="+this+current+"]",clonedRow).attr("for",this+increment);
30 $("input[name="+this+"]",clonedRow).attr("id",this+increment);
33 var selects = ["homebranch","location","itemtype","ccode"];
34 jQuery.each(selects,function() {
35 // increment IDs of labels and selects in the clone
36 $("label[for="+this+current+"]",clonedRow).attr("for",this+increment);
37 $("input[name="+this+"]",clonedRow).attr("id",this+increment);
38 $("select[name="+this+"]",clonedRow).attr("id",this+increment);
39 // find the selected option and select it in the clone
40 var selectedVal = $("select#"+this+current).find("option:selected").attr("value");
41 $("select[name="+this+"] option[value="+selectedVal+"]",clonedRow).attr("selected","selected");
44 var quantityrec = parseFloat($("#quantityrec").attr("value"));
46 $("#quantityrec").attr("value",quantityrec);
49 $(".deleteItemBlock").click(function(){
50 $(this).parent().parent().remove();
51 var quantityrec = parseFloat($("#quantityrec").attr("value"));
53 $("#quantityrec").attr("value",quantityrec);