/* * Notes: * The remarks are hidden from web. If you add new remark, please hide it from Web Browser. * The reason is to make this JavaScript File (*.js) load faster. */ /* * Description * Contains functions needed to perform field operations * Author * SNT Lotus Notes Development Team, 2005 * First created at 2002, PKY. * Function Declaration: * > Combobox Related Functions * function getComboBoxIndex( Object objCmb, String txtValue ) : Integer * function setComboBox( Object cmb, String pValue ) : void * function setComboBoxByValue( Object cmb, String pValue ) : void * function AddNewOption( String pStringValue, String pString, Object objField ) : void * function insertSelectedOptions( strOptSource, strOptDestination ) : void * function getComboxBoxDefaultOption( Object cmb, String pReturntype ) : String * > Radio Button Related Functions * function getRadioButtonSelectedIndex( objRadio ) : Integer * function getRadioButtonSelectedValue( objRadio ) : String * > Checkbox Related Functions * function processCheckBox( Object objChkBox, String txtCommand ) : void * function getChekBoxSelectedIndex( Object objChkBox, String txtValue ) : Integer * function isCheckBoxChecked( Object objChkBox, String txtCheckBoxValue ) : Boolean * function saveCheckedValue( Object sourceChkBoxField, Object destinationMultiValueField ) : void * function restoreCheckedValue( Object sourceMultiValueField, Object destinationChkBoxField ) : void * function isAtLeastOneOptionChecked( objChkBox ) : Boolean * > Options Related Functions * NOTES: to add new option, use AddNewOption function above * function setListboxValue( Object objListbox, String txtCommand ) : Boolean * function deleteAnItem( Object theList, String itemNo) : void * function deleteAllOption( Object objField ) : void * function deleteSelectedOptions( Object objField ) : void * > Lotus Domino Specific Functions * function addselected( Object objchk, String vDocUNID, Object objSelectedField ) : Text List * > Validation Related Functions * function checkCompulsaryTextField( String vFieldName, String pDisplayName, Array vArrFieldControl ) : Array * function checkAtLeastOneTextFieldFilled( vFieldNameList, pDisplayName, vArrFieldControl ) : Array * function checkCompulsaryComboBoxField( String vFieldName, String pDisplayName, String pChkTextOrValue, Array vArrFieldControl ):Array * function checkValidDateField( String vFieldName, String pDisplayName, Array vArrFieldControl ) : Array * function checkValidEmailField( String vFieldName, String pDisplayName, Array vArrFieldControl ) : Array * function appendEmptyField( String vFieldName, String pDisplayName, Array vArrFieldControl ) : Array * function appendErrorField( String vFieldName, String pDisplayName, Array vArrFieldControl ) : Array * Version * Version 1.3 * Last Modified * 04/10/2005 PM, PKY */ //==================== Combobox Related Functions ======================================================= /* * @Usage : From the given combobox field and the value in the field, get the * postion of the value in the combobox. * @Return : Integer. If the txtValue is found in objCmb, the postion is returned. * Else, -1 is returned. * @Param * objCmb : [Object] The combobox field. * txtValue : String. The value to be search in the combobox. */ function getComboBoxIndex( objCmb, txtValue ){ for (m=0; m-1; i-- ){ objField.options[ i ]=null; } } /* * @Usage : Given a list item (combobox or listbox) and the item no, delete all the options inside. * @Return : void * @Param * theList : [Object] The combobox or listbox field. */ function deleteSelectedOptions( objField ){ vLength = objField.options.length; for ( i=vLength-1; i>=0; i-- ){ if ( objField.options[ i ].selected ){ objField.options[ i ]=null; } } } //==================== Lotus Domino Specific Functions =========================================================== /* * @Usage : Pass value of document id to a multivalue field. * @Return : textList * @Param * objchk : [Object], The checkbox field * vDocUNID : String, The document unique id to be add or remove from the multiple field * objSelectedField : [Object], The multivalue field */ function addselected( objchk, vDocUNID, objSelectedField ){ f = document.forms[0]; if( objchk.checked ){ if( objSelectedField.value == "" ){ objSelectedField.value = vDocUNID; }else{ objSelectedField.value = objSelectedField.value + "," + vDocUNID; } }else{ objSelectedField.value = removeFromList( vDocUNID, objSelectedField.value, "," ); } } /* * @Usage : add entries to a multivalue field. the 2nd field is totally depends on the 1st field. * @Return : void * @Param * objchk : [Object], The checkbox field * strValue1 : String, value to be inserted to objTextField1, seperate using strSeperator1 * objTextField1 : [Object], The multivalue field that store the data of strValue1 * strSeperator1 : String, the seperator that used to seperate entries in objTextField1 * strSortOption : String, define how to insert the value for strValue1 and strValue2. Values: "ASC", "DES", "NONE". * if "" specified, treat as "NONE" * strValue2 : OPTIONAL, pass "". String, value to be inserted to objTextField2, seperate using strSeperator2 * objTextField2 : OPTIONAL, pass "". [Object], The multivalue field that store the data of strValue2 * strSeperator2 : OPTIONAL, pass "". String, the seperator that used to seperate entries in objTextField2 * @NOTES : All comparision and checking will based on strValue1 and objTextField1 */ function addselected2( objChkBox, strValue1, objTextField1, strSeperator1, strSortOption, strValue2, objTextField2, strSeperator2 ){ f = document.forms[0]; if ( strSeperator1=="" ){ strSeperator1="," } if ( strSeperator2=="" ){ strSeperator2="," } vField1=objTextField1.value; vField2=""; if ( objTextField2!="" ){ vField2 = objTextField2.value; } if( objChkBox.checked ){ if( vField1 == "" ){ vField1 = strValue1; if ( objTextField2!=""){ vField2 = strValue2; } }else{ vField1 += strSeperator1 + strValue1; if ( objTextField2!="" ){ vField2 = vField2 + strSeperator2 + strValue2; } } objTextField1.value=""; if ( objTextField2!=""){ objTextField2.value="" } improvedBubbleSort( vField1.split( strSeperator1 ), objTextField1, strSeperator1, "ASC" ); if ( objTextField2!="" ){ improvedBubbleSort( vField2.split( strSeperator2 ), objTextField2, strSeperator2, "ASC" ); } }else{ objTextField1.value = removeFromList( strValue1, objTextField1.value, strSeperator1 ); if ( objTextField2!="" ){ objTextField2.value = removeFromList( strValue2, objTextField2.value, strSeperator2 ); } } } //==================== Validation Related Functions =========================================================== /* * The validation checking is standard methold of JavaScript since ESyariah SPKMS v2, where all the validation will done at once, * and the field that are error or empty are listed in the Message Box. Some fixed code must be also availabel in the calling function * to make this code working perfectly. */ /* * @Usage : Given the field name, check if the TEXT FIELD is EMPTY, and return the value in the Array. * @Return : Array of string * @Param * vFieldName : String, the field name to check * pDisplayName : String, the text to be displayed in the message box * vArrFieldControl : Array of String [3] * vArrFieldControl[ 0 ] = vEmptyFieldName * vArrFieldControl[ 1 ] = vErrorFieldName * vArrFieldControl[ 2 ] = vFirstField */ function checkCompulsaryTextField( vFieldName, pDisplayName, vArrFieldControl ){ var f = document.forms[0]; var objTextField = eval( "f." + vFieldName ); if ( objTextField.value==""){ setAsEmptyField( vFieldName ); vArrFieldControl[ 0 ] +="\n- " + pDisplayName; if ( vArrFieldControl[ 2 ]=="" ){ vArrFieldControl[ 2 ]=vFieldName }; }else{ setAsNormalField( vFieldName ); } return vArrFieldControl; } /* * @Usage : Given the field name list, check if the all TEXT FIELD is EMPTY, and return the value in the Array. * If all text field is empty, then return error. Else, mark them as normal field. * @Return : Array of string * @Param * vFieldNameList : String, the lists of fields needs to be checked, seperated by comma ( , ) * pDisplayName : String, the text to be displayed in the message box * vArrFieldControl : Array of String [3] * vArrFieldControl[ 0 ] = vEmptyFieldName * vArrFieldControl[ 1 ] = vErrorFieldName * vArrFieldControl[ 2 ] = vFirstField */ function checkAtLeastOneTextFieldFilled( vFieldNameList, pDisplayName, vArrFieldControl ){ var f = document.forms[0]; vArrFieldName=vFieldNameList.split(','); var filled=false; for ( i=0; i= 0 ){ if ( objTextField.options[ vIndex ].text !="" ){ filled=true; }; } break; default : if ( objTextField.value!=""){ filled=true; }; } } for ( i=0; i