var width = parseInt( document.getElementById('customid0').value, 10);
var height = parseInt( document.getElementById('customid1').value, 10);
var conditions = [
[0, 100, [ // width = 0..100
[0, 50, [ // height = 0..50
67.22 // price = 67.02
]],
[50, 100, [ // height = 50..100
103.34 // price = 103.34
]],
[100, 130, [ // height = 100..130
133.11 // price = 133.11
]]
]],
[101, 125, [ // width = 101..125
[0, 50, [ // height = 0..50
76.69 // ...
]],
[51, 100, [
113.01
]],
[101, 130, [
146.05
]]
]],
[126, 150, [
[0, 50, [
83.69
]],
[51, 100, [
124.74
]],
[101, 130, [
161.28
]]
]]
];
for ( var w = 0, w_len = conditions.length; w < w_len; w += 1 )
{
if ( width >= conditions[w][0] && width <= conditions[w][1] )
{
for ( var h = 0, h_len = conditions[w][2].length; h < h_len; h += 1 )
{
if ( height >= conditions[w][2][h][0] && height <= conditions[w][2][h][1] )
{
price = conditions[w][2][h][2];
break;
}
}
}
}
Проверьте Fiddle здесь .