@@ -51,29 +51,34 @@ function trim(value) {
5151 return temp ;
5252}
5353
54- function updateList ( ) {
55- // write back to opener window
54+ function determineList ( ) {
55+ // generate a comma-separated list of the checked items
5656 if ( document . frm_help . check == undefined ) { return ; }
5757 var list = new Array ( ) ;
58- for ( box = 0 ; box < document . frm_help . check . length ; box ++ ) {
59- if ( document . frm_help . check [ box ] . checked ) {
60- list . push ( document . frm_help . check [ box ] . value ) ;
58+ if ( document . frm_help . check . length == undefined ) {
59+ if ( document . frm_help . check . checked ) {
60+ list . push ( document . frm_help . check . value ) ;
61+ }
62+ } else {
63+ for ( box = 0 ; box < document . frm_help . check . length ; box ++ ) {
64+ if ( document . frm_help . check [ box ] . checked ) {
65+ list . push ( document . frm_help . check [ box ] . value ) ;
66+ }
6167 }
6268 }
63- window . opener . document . itemSynopsis [ field ] . value = list . join ( "," ) ;
69+ return new String ( list . join ( ',' ) ) ;
70+ }
71+
72+ function updateList ( ) {
73+ // write back to opener window
74+ if ( document . frm_help . check == undefined ) { return ; }
75+ window . opener . document . itemSynopsis [ field ] . value = determineList ( ) ;
6476}
6577
6678function updatePreview ( ) {
67- // add new checkbox selections to preview
79+ // update the preview box
6880 if ( document . frm_help . check == undefined ) { return ; }
69- var list = new Array ( ) ;
70- for ( box = 0 ; box < document . frm_help . check . length ; box ++ ) {
71- if ( document . frm_help . check [ box ] . checked ) {
72- list . push ( document . frm_help . check [ box ] . value ) ;
73- }
74- }
75- listString = new String ( list . join ( ',' ) ) ;
76- writePreview ( listString ) ;
81+ writePreview ( determineList ( ) ) ;
7782}
7883
7984function clearList ( ) {
@@ -89,8 +94,8 @@ function reviseList(vals) {
8994 if ( document . frm_help . check == undefined ) { return ; }
9095 var to_check ;
9196 var list = vals . split ( "," ) ;
92- for ( box = 0 ; box < document . frm_help . check . length ; box ++ ) {
93- check = document . frm_help . check [ box ] ;
97+ if ( document . frm_help . check . length == undefined ) {
98+ check = document . frm_help . check ;
9499 to_check = false ;
95100 for ( val in list ) {
96101 if ( check . value == trim ( list [ val ] ) ) {
@@ -99,16 +104,8 @@ function reviseList(vals) {
99104 }
100105 }
101106 check . checked = to_check ;
102- }
103- }
104-
105- function resetList ( ) {
106- // reset preview and check boxes to initial values
107- if ( document . frm_help . check == undefined ) { return ; }
108- var to_check ;
109- var list = original_field . split ( ',' ) ;
110- writePreview ( list ) ;
111- for ( box = 0 ; box < document . frm_help . check . length ; box ++ ) {
107+ } else {
108+ for ( box = 0 ; box < document . frm_help . check . length ; box ++ ) {
112109 check = document . frm_help . check [ box ] ;
113110 to_check = false ;
114111 for ( val in list ) {
@@ -118,9 +115,17 @@ function resetList() {
118115 }
119116 }
120117 check . checked = to_check ;
118+ }
121119 }
122120}
123121
122+ function resetList ( ) {
123+ // reset preview and check boxes to initial values
124+ if ( document . frm_help . check == undefined ) { return ; }
125+ writePreview ( original_field ) ;
126+ reviseList ( original_field ) ;
127+ }
128+
124129function writePreview ( val ) {
125130 // writes a value to the text_preview
126131 document . frm_help . text_preview . value = val ;
0 commit comments