var ff; // firefox compatibilityvar ie; // ie compatibilityvar url = "ClassLibraries/DataOperations/xmlresponse/GET/getDepts.php?cmpyid=";var profilesURL = "ClassLibraries/DataOperations/xmlresponse/GET/getProfiles.php?deptid="; var profileIDURL = "ClassLibraries/DataOperations/xmlresponse/GET/getProfileData.php?profileid=";var getAreasURL = "ClassLibraries/DataOperations/xmlresponse/GET/getWorkAreasData.php";var getAreaSelectURL = "ClassLibraries/DataOperations/xmlresponse/GET/getAreaSelect.php?profileid="; function fullRequestFormInitializationOnRefresh(){ var companyDrpDown = document.getElementById("companiesDrpDown"); var inputs = document.getElementsByTagName('input'); var editRequestDrpDown = document.getElementById('editRequestDrpDown'); if(editRequestDrpDown) { (ff == true) ? editRequestDrpDown.options[0].selected = true : editRequestDrpDown.options[0].setAttribute('selected', 'selected'); } for(var i=0; i<companyDrpDown.length; i++){ if(companyDrpDown.options[i].text == 'SELECT'){ (ff == true) ? companyDrpDown.options[i].selected = true : companyDrpDown.options[i].setAttribute('selected', 'selected'); } } for(var i=0; i<inputs.length; i++){ if(inputs[i].type == 'checkbox'){ inputs[i].checked = false; } } // clear any previous menu options //initializeDeptInputAndDropDown(); //initializeProfilesInputAndDropDown(); //initializeOtherProfileFields(); }// query server side about a particular area via profile ID and then// get it's salary ID to found out the areafunction getAreaSelectHttpResponse(){ var areaDrpDown = document.getElementById("areaDrpDown"); var workLevelDrpDown = document.getElementById("workLevelDrpDown"); var salaryIDHiddenInput = document.getElementById("salaryIDHiddenInput"); if (http.readyState == 4 && http.status == 200) { if (http.responseText.indexOf('invalid') == -1) { //alert(http.responseXML); // Use the XML DOM to unpack the data sent var xmlDocument = http.responseXML; var xmlData = xmlDocument.getElementsByTagName('AreaData')[0]; var area = xmlData.getElementsByTagName('area'); var profileSalaryID = xmlData.getElementsByTagName('salaryID'); var workLevels = xmlData.getElementsByTagName('workLevel'); var workSalaryIDs = xmlData.getElementsByTagName('workLevelSalaryID'); var profileAreaMatch = false; var salaryIDMatch = false; profileArea = area[0].firstChild.data; profileWorkLevel = profileSalaryID[0].firstChild.data; // go through drop down and find area that matches the queried area for(var i=0; i<areaDrpDown.length; i++) { if(profileArea == areaDrpDown.options[i].text) { // set that area as inital selected item // cross browser compatibility (ff == true) ? areaDrpDown.options[i].selected = true : areaDrpDown.options[i].setAttribute('selected', 'selected'); profileAreaMatch = true; }else { if(areaDrpDown.options[i].text == 'SELECT') { // cross browser compatibility (ff == true) ? areaDrpDown.options[i].selected = true : areaDrpDown.options[i].setAttribute('selected', 'selected'); areaDrpDown.options[i].text = null; } } } initializeParentNode(workLevelDrpDown); initializeTextInput(salaryIDHiddenInput); // populate the work levels select menu for(var i=0; i<workLevels.length; i++) { var optionWorkLevel = document.createElement("option"); var text = document.createTextNode(workLevels[i].firstChild.data); optionWorkLevel.appendChild(text); optionWorkLevel.value = workSalaryIDs[i].firstChild.data; // set the work level to the corresponding salary id found in profile if(profileWorkLevel == optionWorkLevel.value){ //alert('areaselect response' + profileArea); // cross browser compatibility (ff === true) ? optionWorkLevel.selected = true : optionWorkLevel.setAttribute('selected', 'selected'); // set the hidden input field salaryIDHiddenInput salaryIDHiddenInput.value = workSalaryIDs[i].firstChild.data; } workLevelDrpDown.appendChild(optionWorkLevel); } } } }// query the server side about all the work level areas and populate the select menu// areaDrpDown back to caller functionfunction getAreasHttpResponse(){ var areaDrpDown = document.getElementById("areaDrpDown"); var profilesDrpDown = document.getElementById("positionProfileDrpDown"); if (http.readyState == 4 && http.status == 200) { if (http.responseText.indexOf('invalid') == -1) { //alert('getAreasHttpResponse' + http.responseText); var xmlDocument = http.responseXML; var xmlData = xmlDocument.getElementsByTagName('workAreasData')[0]; var numberOfSalaryIDs = xmlData.getElementsByTagName('salaryID'); var numberOfAreas = xmlData.getElementsByTagName('area'); if(numberOfSalaryIDs) { for(var i=0; i<numberOfSalaryIDs.length; i++) { var salaryID = numberOfSalaryIDs[i].firstChild.data; var area = numberOfAreas[i].firstChild.data; var optionTag = document.createElement("option"); optionTag.value = salaryID; var text = document.createTextNode(area); optionTag.appendChild(text); //optionTag.text = area; // populate the dept drop down menu areaDrpDown.appendChild(optionTag); } if(profilesDrpDown.length >= 1) { // set the worklevel to the salary set in the profiles select // menu just in case, this is a work instead of putting this code // in "getProfileIDHttpResponse" profileID = profilesDrpDown.options[profilesDrpDown.selectedIndex].value; setAreaSelect(profileID); } } } } }// retrieve all data corresonding to particular Profile Position ID queried// to the systemfunction getProfileIDHttpResponse(){ var profilesDrpDown = document.getElementById("positionProfileDrpDown"); var locationTextInput = document.getElementById("locationTextInput"); var minBaseTextInput = document.getElementById("minimumBaseRange"); var maxBaseTextInput = document.getElementById("maximumBaseRange"); var workLevelDrpDown = document.getElementById("workLevelDrpDown"); var salaryIDHiddenInput = document.getElementById("salaryIDHiddenInput"); if (http.readyState == 4 && http.status == 200) { if (http.responseText.indexOf('invalid') == -1) { //alert(http.responseText); var xmlDocument = http.responseXML; var xmlData = xmlDocument.getElementsByTagName('profileTemplate')[0]; var profileID = xmlData.getElementsByTagName('profileID'); var profileTitle = xmlData.getElementsByTagName('profileTitle'); var profileLocation = xmlData.getElementsByTagName('location'); var workArea = xmlData.getElementsByTagName('area'); var salaryID = xmlData.getElementsByTagName('salaryID'); var minimumBase = xmlData.getElementsByTagName('minimumBase'); var maximumBase = xmlData.getElementsByTagName('maximumBase'); //var workData = xmlData.getElementsByTagName('workData')[0]; //var workLevels = workData.getElementsByTagName('workLevel'); //var workSalaryId = workData.getElementsByTagName('workSalaryID'); var workLevel; if(profileLocation.length >= 1){ locationTextInput.value = profileLocation[0].firstChild.data; } //alert('getProfilesIDHttpResponse' + http.readyState); // initialize work level dropdowns initializeParentNode(workLevelDrpDown); // initialize hidden salary ID initializeTextInput(salaryIDHiddenInput); if(salaryID && salaryID.length >= 1){ getAreasDrpDown(); } if(minimumBase.length >= 1){ minBaseTextInput.value = minimumBase[0].firstChild.data; }else{ minBaseTextInput.value = ''; } if(maximumBase.length >= 1){ maxBaseTextInput.value = maximumBase[0].firstChild.data; }else{ maxBaseTextInput.value = ''; } // salary ID in hidden input field if(salaryID[0].firstChild.data >= 1){ salaryIDHiddenInput.value = salaryID[0].firstChild.data; }else{ salaryIDHiddenInput.value = ''; } } } }// does the actual getting of the data from the server to xml format to client side // retrieves all the correspond data for a particular profile title based on the // previous dept drop menus selection / dept id which is then used to query the// databasefunction getProfilesHttpResponse(){ var profilesDrpDown = document.getElementById("positionProfileDrpDown"); if (http.readyState == 4 && http.status == 200) { if (http.responseText.indexOf('invalid') == -1) { //alert(http.readyState); // Use the XML DOM to unpack the data sent var xmlDocument = http.responseXML; var xmlData = xmlDocument.getElementsByTagName('profilesData')[0]; var numberOfProfileIDs = xmlData.getElementsByTagName('profileID'); var numberOfProfileNames = xmlData.getElementsByTagName('profileTitle'); // retrieve the array of Dept data from server side function //alert(numberOfProfileIDs.length); if(numberOfProfileIDs.length >= 1){ // fill the select object options "departmentDrpDown" with values // values of deptIDs and names of deptNames for(var i=0; i<numberOfProfileIDs.length; i++){ var profileid = numberOfProfileIDs[i].firstChild.data; var profilename = numberOfProfileNames[i].firstChild.data; // create default option "select" with value "initialSelection" if(i < 1){ var optionDefault = document.createElement("option"); optionDefault.value = 'initialSelection'; var text = document.createTextNode('SELECT'); optionDefault.appendChild(text); //optionDefault.text = 'SELECT'; optionDefault.setAttribute('selected', 'selected'); // populate the dept drop down with default menu option profilesDrpDown.appendChild(optionDefault); } var optionTag = document.createElement("option"); optionTag.value = profileid; var text = document.createTextNode(profilename); optionTag.appendChild(text); // populate the dept drop down menu profilesDrpDown.appendChild(optionTag); } } } }}// The server-side to client script function // retrieve all the departments from the server-side script function// and populate the departments drop down list whenever a user selects the// first menu from the company(s) drop down listfunction getDeptsHttpResponse(){if (http.readyState == 4 && http.status == 200) { if (http.responseText.indexOf('invalid') == -1) { // Use the XML DOM to unpack the data sent var xmlDocument = http.responseXML; var xmlData = xmlDocument.getElementsByTagName('deptData')[0]; var numberOfDeptIDs = xmlData.getElementsByTagName('deptID'); var numberOfDeptNames = xmlData.getElementsByTagName('deptName'); var deptDrpDown = document.getElementById("departmentDrpDown"); var changeDeptNameInput = document.getElementById("changeDeptNameTextInput"); // retrieve the array of Dept data from server side function // alert(numberOfDeptIDs.length); if(numberOfDeptIDs.length >= 1) { // fill the select object options "departmentDrpDown" with values // values of deptIDs and names of deptNames for(var i=0; i<numberOfDeptIDs.length; i++) { var deptid = numberOfDeptIDs[i].firstChild.data; var deptname = numberOfDeptNames[i].firstChild.data; // create default option "select" with value "initialSelection" if(i < 1) { var optionDefault = document.createElement("option"); optionDefault.value = 'initialSelection'; var text = document.createTextNode('SELECT'); optionDefault.appendChild(text); //optionDefault.text = 'SELECT'; optionDefault.setAttribute('selected', 'selected'); // populate the dept drop down with default menu option deptDrpDown.appendChild(optionDefault); } var optionTag = document.createElement("option"); optionTag.value = deptid; var text = document.createTextNode(deptname); optionTag.appendChild(text); // populate the dept drop down menu deptDrpDown.appendChild(optionTag); } } } } }var isWorking = false;function getHTTPObject() { var xmlhttp; try { // Firefox, Opera 8.0+, Safari xmlhttp=new XMLHttpRequest(); // for conditional code statements ff = true; } catch (e) { // Internet Explorer try { xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); // for conditional code statements ie = true; } catch (e) { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); // for conditional codes statements ie = true; } } return xmlhttp; } function initializeTextInput(object){ if(object) { object.value = ''; }} // empty all childNodes in a parent nodefunction initializeParentNode(object){ if(object) { while(object.childNodes.length > 0) { object.removeChild(object.childNodes[0]); } }} // set the drop menu to matching area that profile template has// use area corresponding to the profile area found in the templates// via Profile ID to areafunction setAreaSelect(profileID){ var areaDrpDown = document.getElementById("areaDrpDown"); if (http.readyState == 4 && http.status == 200) { if(areaDrpDown.length >= 1) { //alert('setarea' + http.readyState + 'profileid' + profileID); http.open("GET", getAreaSelectURL + escape(profileID), true); http.onreadystatechange = getAreaSelectHttpResponse; http.send(null); isWorking = true; } } }// update the select menu containing all the after the companies select menu// which is the departments select menu, then fill it with// corresponding department data depending on the selection // in the previous select menu departmentDrpDown function updateDepartmentsDrpDown(){ var companyDrpDown = document.getElementById("companiesDrpDown"); var companyID = companyDrpDown.options[companyDrpDown.selectedIndex].value; var deptDrpDown = document.getElementById("departmentDrpDown"); var changeDeptNameInput = document.getElementById("changeDeptNameTextInput"); var areaDrpDown = document.getElementById("areaDrpDown"); var profilesDrpDown = document.getElementById("positionProfileDrpDown"); var workLevelDrpDown = document.getElementById("workLevelDrpDown"); var minBase = document.getElementById("minimumBaseRange"); var maxBase = document.getElementById("maximumBaseRange"); // clear any previous menu options initializeParentNode(deptDrpDown); initializeParentNode(profilesDrpDown); initializeParentNode(areaDrpDown); initializeParentNode(workLevelDrpDown); initializeTextInput(minBase); initializeTextInput(maxBase); http.open("GET", url + escape(companyID), true); http.onreadystatechange = getDeptsHttpResponse; http.send(null); isWorking = true; }// update the select menu containing all the corresponding position titles// depending on the selection in the previous select menu departmentDrpDown // this function depends on the selection in departmentDrpDown this is used by// select menu id departmentDrpDownfunction updateProfilesDrpDown(){ var profilesDrpDown = document.getElementById("positionProfileDrpDown");var areaDrpDown = document.getElementById("areaDrpDown"); var workLevelDrpDown = document.getElementById("workLevelDrpDown");var minBase = document.getElementById("minimumBaseRange");var maxBase = document.getElementById("maximumBaseRange"); if (http.readyState == 4 && http.status == 200) { var deptDrpDown = document.getElementById("departmentDrpDown"); var deptID = deptDrpDown.options[deptDrpDown.selectedIndex].value; // initialize area, work level and salary ranges and profile titles // and salary ranges initializeParentNode(profilesDrpDown); initializeParentNode(areaDrpDown); initializeParentNode(workLevelDrpDown); initializeTextInput(minBase); initializeTextInput(maxBase); http.open("GET", profilesURL + escape(deptID), true); http.onreadystatechange = getProfilesHttpResponse; http.send(null); isWorking = true; }}// update the area drop down menu with a selection of work level areas// with each option having it's corresponding salary for each of the four// work level areas use the salary ID if any is found in the position profile// to automatically set that work level area as default in the areas drop down// menufunction getAreasDrpDown(){ var profilesDrpDown = document.getElementById("positionProfileDrpDown"); if (http.readyState == 4 && http.status == 200) { if(profilesDrpDown.length >= 1) { //alert('getAreasDrpDown' + http.readyState); http.open("GET", getAreasURL, true); http.onreadystatechange = getAreasHttpResponse; http.send(null); isWorking = true; } }}// used by select item ID positionProfileDrpDown to update fields relevant to// a PARTICULAR selected position profile title in select menu ID // positionProfileDrpDownfunction updateOtherProfileFields(){ var profilesDrpDown = document.getElementById("positionProfileDrpDown"); var areaDrpDown = document.getElementById("areaDrpDown"); var workLevelDrpDown = document.getElementById("workLevelDrpDown"); var minBase = document.getElementById("minimumBaseRange"); var maxBase = document.getElementById("maximumBaseRange"); // pass the profile ID to retrieve the area and salary data var selectedValue = profilesDrpDown.options[profilesDrpDown.selectedIndex].value; // clear all the area select menus, work level select menus and salary ranges // to be prepared for new updates initializeParentNode(areaDrpDown); initializeParentNode(workLevelDrpDown); initializeTextInput(minBase); initializeTextInput(maxBase); if (http.readyState == 4 && http.status == 200) { http.open("GET", profileIDURL + escape(selectedValue), true); http.onreadystatechange = getProfileIDHttpResponse; http.send(null); isWorking = true; }}var http = getHTTPObject(); // We create the HTTP Object