From: <pee...@us...> - 2003-05-21 06:47:34
|
Update of /cvsroot/digir/web In directory sc8-pr-cvs1:/tmp/cvs-serv8874 Modified Files: commonFunctions.js searchForm.jsp searchFunctions.js Log Message: fixed problem with custom handling regarding required elements and switching infodos Index: commonFunctions.js =================================================================== RCS file: /cvsroot/digir/web/commonFunctions.js,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** commonFunctions.js 20 May 2003 06:35:02 -0000 1.6 --- commonFunctions.js 21 May 2003 06:47:30 -0000 1.7 *************** *** 143,147 **** if (lastOne) //add submit button { ! code += "<td><input type='submit' value='Submit query' onclick='javascript:validateForm()'/></td>\n"; } else --- 143,147 ---- if (lastOne) //add submit button { ! code += "<td><input type='button' value='Submit query' onclick='javascript:validateForm()'/></td>\n"; } else Index: searchForm.jsp =================================================================== RCS file: /cvsroot/digir/web/searchForm.jsp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** searchForm.jsp 20 May 2003 06:35:05 -0000 1.5 --- searchForm.jsp 21 May 2003 06:47:31 -0000 1.6 *************** *** 539,543 **** } %> ! <option value="--">----------------------------------------</option> </select> </td> --- 539,543 ---- } %> ! <option value="--">---------------------------------------------------</option> </select> </td> *************** *** 578,582 **** } %> ! <option value="--">----------------------------------------</option> </select> <input type="hidden" name="resultDataPoints" value=""> --- 578,582 ---- } %> ! <option value="--">---------------------------------------------------</option> </select> <input type="hidden" name="resultDataPoints" value=""> Index: searchFunctions.js =================================================================== RCS file: /cvsroot/digir/web/searchFunctions.js,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** searchFunctions.js 20 May 2003 06:35:06 -0000 1.8 --- searchFunctions.js 21 May 2003 06:47:31 -0000 1.9 *************** *** 63,69 **** --- 63,88 ---- } + var numf = fields.length; + var foundField = false; for (i=0; i<numc; i++) { tmpf = fieldValues[i]; + + //see if tmpf is a valid field for this form + foundField = false; + for (f=0; f<numf; f++) + { + if (fields[f] == tmpf) + { + foundField=true; + break; + } + } + if (!foundField) + { + tmpf = "--"; //wasn't found, default + } + + tmpc = copValues[i]; tmpv = valueValues[i]; *************** *** 629,658 **** var optionValue = null; var optionText = null; - var cnt = values.length; var obj2 = document.s.resultSelections; var shortenCnt = 0; for(j=0; j<cnt; j++) { optionValue = values[j]; - optionText = translate(optionValue,fieldTrans); ! if (isRequired[optionValue] == true) ! { ! obj2.options[j] = new Option(optionText + " *", optionValue); ! } ! else { ! obj2.options[j] = new Option(optionText, optionValue); } - showDataPoints[optionValue] = false; - shortenCnt++; } //add spacer to selected list if (obj2.options[obj2.length-1].value != "--") { obj2.options[obj2.length] = ! new Option("----------------------------------------","--"); } --- 648,709 ---- var optionValue = null; var optionText = null; var obj2 = document.s.resultSelections; var shortenCnt = 0; + var idx = 0; + + //first add all the values from the original obj2 to the end values array. + //(we do this because the original obj2 contains the (if any) required + //fields. they must be added in if they are not in the cookie. this + //situation occurs because of super stickiness across infodos.) + //note: appending all requireds to the end could introduce a dupe. + var cnt2 = obj2.length; + for(i=0; i<cnt2; i++) + { + optionValue = obj2.options[i].value; + if (optionValue != "--") + { + values[values.length] = optionValue; + } + } + //now add all values from the cookie that apply + var cnt = values.length; + var loaded = new Array(cnt); for(j=0; j<cnt; j++) { optionValue = values[j]; ! //first see if this value is a valid field ! var test = showDataPoints[optionValue]; ! if (test != null) //it just needs to be there { ! ! //next ensure we haven't already loaded it ! if (loaded[optionValue] != true) ! { ! optionText = translate(optionValue,fieldTrans); ! ! if (isRequired[optionValue] == true) ! { ! obj2.options[idx] = new Option(optionText + " *", optionValue); ! } ! else ! { ! obj2.options[idx] = new Option(optionText, optionValue); ! } ! loaded[optionValue]=true; ! idx++; ! showDataPoints[optionValue] = false; ! shortenCnt++; ! } } } + //add spacer to selected list if (obj2.options[obj2.length-1].value != "--") { obj2.options[obj2.length] = ! new Option("---------------------------------------------------","--"); } *************** *** 695,699 **** { obj2.options[obj2.length] = ! new Option("----------------------------------------","--"); } --- 746,750 ---- { obj2.options[obj2.length] = ! new Option("---------------------------------------------------","--"); } *************** *** 759,763 **** { obj2.options[obj2.length] = ! new Option("----------------------------------------","--"); } --- 810,814 ---- { obj2.options[obj2.length] = ! new Option("---------------------------------------------------","--"); } *************** *** 809,813 **** if (obj1.options[obj1.length-1].value != "--") { ! obj1.options[obj1.length] = new Option("----------------------------------------","--"); } --- 860,864 ---- if (obj1.options[obj1.length-1].value != "--") { ! obj1.options[obj1.length] = new Option("---------------------------------------------------","--"); } |