From 5ae95ca8b945cec145387a2ef764ec46213e1818 Mon Sep 17 00:00:00 2001 From: "myk%mozilla.org" <> Date: Tue, 14 Dec 2004 10:29:56 +0000 Subject: Fix for bug 241814: properly trim component fields according to product selection in the request queue, flag type editing, and anywhere else that uses the same code; r=vladd, a=justdave --- productmenu.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'productmenu.js') diff --git a/productmenu.js b/productmenu.js index d917d325c..e633ab327 100644 --- a/productmenu.js +++ b/productmenu.js @@ -203,19 +203,26 @@ function selectProduct( f , productfield, componentfield, blank ) { // - is_diff says if it's a full list or just a list of products that // were added to the current selection. // - single indicates if a single item was selected + // - selectedIndex is the index of the first selected item + // - selectedValue is the value of the first selected item var sel = Array(); var is_diff = 0; var single; - - // if nothing selected, pick all - if ( f[productfield].selectedIndex == -1 ) { - for ( var i = 0 ; i < f[productfield].length ; i++ ) { + var selectedIndex = f[productfield].selectedIndex; + var selectedValue = f[productfield].options[selectedIndex].value; + + // If nothing is selected, or the selected item is the "blank" value + // at the top of the list which represents all products on drop-down menus, + // then pick all products so we show all components. + if ( selectedIndex == -1 || !cpts[selectedValue]) + { + for ( var i = blank ? 1 : 0 ; i < f[productfield].length ; i++ ) { sel[sel.length] = f[productfield].options[i].value; } single = 0; } else { - for ( i = 0 ; i < f[productfield].length ; i++ ) { + for ( i = blank ? 1 : 0 ; i < f[productfield].length ; i++ ) { if ( f[productfield].options[i].selected ) { sel[sel.length] = f[productfield].options[i].value; } -- cgit v1.2.3-24-g4f1b