summaryrefslogtreecommitdiffstats
path: root/extensions/BMO/web/js/swag.js
blob: 47886b2a926bdc224b5cd4b72df79ae8e6413c62 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/**
 * Swag Request Form Functions
 * Form Interal Swag Request Form
 * dtran
 * 7/6/09
 **/


function evalToNumber(numberString) {
    if(numberString=='') return 0;
    return parseInt(numberString);
}

function evalToNumberString(numberString) {
    if(numberString=='') return '0';
    return numberString;
}
//item_array should be an array of DOM element ids
function getTotal(item_array) {
    var total = 0;
    for(var i in item_array) {
	total += evalToNumber(document.getElementById(item_array[i]).value);
    }
    return total;
}

function calculateTotalSwag() {   
    document.getElementById('Totalswag').value = 
	getTotal( new Array('Lanyards',
			'Stickers',
			'Bracelets',
			'Tattoos',
			'Buttons',
			'Posters'));
    
}


function calculateTotalMensShirts() {   
    document.getElementById('mens_total').value = 
	getTotal( new Array('mens_s',
			'mens_m',
			'mens_l',
			'mens_xl',
			'mens_xxl',
			'mens_xxxl'));
    
}


function calculateTotalWomensShirts() {   
    document.getElementById('womens_total').value = 
	getTotal( new Array('womens_s',
			'womens_m',
			'womens_l',
			'womens_xl',
			'womens_xxl',
			'womens_xxxl'));
    
}