function select_product_dimensions(dimensions_element, node, select_type)
{
// get the selected dimensions
var selected_dimensions = dimensions_element.options[dimensions_element.selectedIndex].value;
// clear the prices
var prices_container = document.getElementById('product_prices');
prices_container.innerHTML = '';
if(select_type == 1)
{
// product only has dimensions
}
else
{
// clear the colours list
var colour_element = document.getElementById('product_colour');
colour_element.options.length = 0;
if(selected_dimensions == "")
{
colour_element.options[0] = new Option("Please select dimensions", "");
return false;
}
// get the total number of colour options for the selected dimensions
var total_colours = 0;
for (var colour in dimensions[selected_dimensions])
{
if(dimensions[selected_dimensions].hasOwnProperty(colour))
{
total_colours++;
}
}
if(total_colours == 0)
{
colour_element.options[0] = new Option("N/A", "N/A");
}
else
{
if(total_colours == 1)
{
var options_count = 0;
}
else
{
colour_element.options[0] = new Option("Please select a colour", "");
var options_count = 1;
}
for (var colour in dimensions[selected_dimensions])
{
if(dimensions[selected_dimensions].hasOwnProperty(colour))
{
colour_element.options[options_count] = new Option(colour, colour);
options_count++;
}
}
// select the colour if only 1 exists
if(total_colours == 1)
{
select_product_colour(colour_element, node);
}
}
}
}
function select_product_colour(colour_element, node)
{
if(!colour_element.options){
//return false;
colour_element = document.getElementById('product_colour');
}
if(colour_element.value == ""){
return false;
}
// get the selected dimensions
var dimensions_element = document.getElementById('product_dimensions');
var selected_dimensions = dimensions_element.options[dimensions_element.selectedIndex].value;
// get the selected colour
var selected_colour = colour_element.options[colour_element.selectedIndex].value;
var prices = dimensions[selected_dimensions][selected_colour];
var html = '
'+
'
| Price per unit | '+ '' + get_price_output(prices['price'], node) + ' | '+ '
| 5 - 9 | '+ '' + get_price_output(prices['5off'], node) + ' | '+ '
| 10 - 19 | '+ '' + get_price_output(prices['10off'], node) + ' | '+ '
| 20 - 49 | '+ '' + get_price_output(prices['20off'], node) + ' | '+ '
| 50 - 99 | '+ '' + get_price_output(prices['50off'], node) + ' | '+ '
| 100+ | '+ '' + get_price_output(prices['100off'], node) + ' | '+ '
Quantity | '+
'