var postEntity = ''; var postGovLevel = ''; var Entity = '\STATE:2:State of Maine|'; // GovLevel data table // // To edit the list, just delete a line or add a line. Order is important. // The order displayed here is the order it appears on the drop down. // var GovLevel = 'STATE:State'; var FiscalPeriod = '\STATE:2:State of Maine:2024 (07/01/23-06/30/24):2024:1|STATE:2:State of Maine:2023 (07/01/22-06/30/23):2023:1|STATE:2:State of Maine:2022 (07/01/21-06/30/22):2022:1|STATE:2:State of Maine:2021 (07/01/20-06/30/21):2021:1|STATE:2:State of Maine:2020 (07/01/19-06/30/20):2020:1|STATE:2:State of Maine:2019 (07/01/18-06/30/19):2019:1|STATE:2:State of Maine:2018 (07/01/17-06/30/18):2018:1|STATE:2:State of Maine:2017 (07/01/16-06/30/17):2017:1|STATE:2:State of Maine:2016 (07/01/15-06/30/16):2016:1|STATE:2:State of Maine:2015 (07/01/14-06/30/15):2015:1|STATE:2:State of Maine:2014 (07/01/13-06/30/14):2014:1|STATE:2:State of Maine:2013 (07/01/12-06/30/13):2013:1|STATE:2:State of Maine:2012 (07/01/11-06/30/12):2012:1|STATE:2:State of Maine:2011 (07/01/10-06/30/11):2011:1|STATE:2:State of Maine:2010 (07/01/09-06/30/10):2010:1|STATE:2:State of Maine:2009 (07/01/08-06/30/09):2009:1|STATE:2:State of Maine:2024 (07/01/23-06/30/24):2024:2|STATE:2:State of Maine:2023 (07/01/22-06/30/23):2023:2|STATE:2:State of Maine:2022 (07/01/21-06/30/22):2022:2|STATE:2:State of Maine:2021 (07/01/20-06/30/21):2021:2|STATE:2:State of Maine:2020 (07/01/19-06/30/20):2020:2|STATE:2:State of Maine:2019 (07/01/18-06/30/19):2019:2|STATE:2:State of Maine:2018 (07/01/17-06/30/18):2018:2|STATE:2:State of Maine:2017 (07/01/16-06/30/17):2017:2|STATE:2:State of Maine:2016 (07/01/15-06/30/16):2016:2|STATE:2:State of Maine:2015 (07/01/14-06/30/15):2015:2|STATE:2:State of Maine:2014 (07/01/13-06/30/14):2014:2|STATE:2:State of Maine:2013 (07/01/12-06/30/13):2013:2|STATE:2:State of Maine:2012 (07/01/11-06/30/12):2012:2|STATE:2:State of Maine:2011 (07/01/10-06/30/11):2011:2|STATE:2:State of Maine:2010 (07/01/09-06/30/10):2010:2|STATE:2:State of Maine:2009 (07/01/08-06/30/09):2009:2|STATE:2:State of Maine:2024 (07/01/23-06/30/24):2024:3|STATE:2:State of Maine:2023 (07/01/22-06/30/23):2023:3|STATE:2:State of Maine:2022 (07/01/21-06/30/22):2022:3|STATE:2:State of Maine:2021 (07/01/20-06/30/21):2021:3|STATE:2:State of Maine:2020 (07/01/19-06/30/20):2020:3|STATE:2:State of Maine:2019 (07/01/18-06/30/19):2019:3|STATE:2:State of Maine:2018 (07/01/17-06/30/18):2018:3|STATE:2:State of Maine:2017 (07/01/16-06/30/17):2017:3|STATE:2:State of Maine:2016 (07/01/15-06/30/16):2016:3|STATE:2:State of Maine:2015 (07/01/14-06/30/15):2015:3|STATE:2:State of Maine:2014 (07/01/13-06/30/14):2014:3|STATE:2:State of Maine:2013 (07/01/12-06/30/13):2013:3|STATE:2:State of Maine:2012 (07/01/11-06/30/12):2012:3|STATE:2:State of Maine:2011 (07/01/10-06/30/11):2011:3|STATE:2:State of Maine:2010 (07/01/09-06/30/10):2010:3|STATE:2:State of Maine:2009 (07/01/08-06/30/09):2009:3|'; function TrimString(sInString) { if ( sInString ) { sInString = sInString.replace( /^\s+/g, "" );// strip leading return sInString.replace( /\s+$/g, "" );// strip trailing } } // Populates the GovLevel selected with the counties from the GovLevel list function populateGovLevel(defaultGovLevel) { if ( postGovLevel != '' ) { defaultGovLevel = postGovLevel; } var GovLevelLineArray = GovLevel.split('|'); // Split into lines var selObj = document.getElementById('govLevel'); // selObj.options[0] = new Option('--- Select ---',''); // selObj.selectedIndex = 0; for (var loop = 0; loop < GovLevelLineArray.length; loop++) { lineArray = GovLevelLineArray[loop].split(':'); GovLevelCode = TrimString(lineArray[0]); GovLevelName = TrimString(lineArray[1]); if ( GovLevelCode != '' ) { selObj.options[loop] = new Option(GovLevelName, GovLevelCode); } if ( defaultGovLevel == GovLevelCode ) { selObj.selectedIndex = loop; } } } //populate fiscal period function populateFiscalPeriod() { var selObj = document.getElementById('year'); var foundEntity = false; // Empty options just in case new drop down is shorter if ( selObj.type == 'select-one' ) { for (var i = 0; i < selObj.options.length; i++) { selObj.options[i] = null; } selObj.options.length=null; selObj.options[0] = new Option('',''); selObj.selectedIndex = 0; } // Populate the drop down with Entities from the selected GovLevel var FiscalPeriodLineArray = FiscalPeriod.split("|"); // Split into lines var optionCntr = 0; for (var loop = 0; loop < FiscalPeriodLineArray.length; loop++) { lineArray = FiscalPeriodLineArray[loop].split(":"); GovLevelCode = TrimString(lineArray[0]); EntityCode = TrimString(lineArray[1]); EntityName = TrimString(lineArray[2]); FiscalCode = TrimString(lineArray[3]); FiscalName = TrimString(lineArray[4]); transType = TrimString(lineArray[5]); ////document.getElementById('EntitySelect').value == EntityCode && if (document.getElementById('entityId').value==EntityCode && EntityCode != '' && document.getElementById('trans_type').value==transType ) { if ( selObj.type == 'text' ) { parentObj = document.getElementById('year').parentNode; parentObj.removeChild(selObj); var inputSel = document.createElement("SELECT"); inputSel.setAttribute("name","year"); inputSel.setAttribute("id","year"); parentObj.appendChild(inputSel) ; } if (document.getElementById('trans_type').value==transType && FiscalCode!= '' && EntityCode != '') { // selObj.options[optionCntr] = new Option(FiscalCode, FiscalName); selObj.options[optionCntr] = new Option(FiscalName, FiscalName); } // See if it's selected from a previous post if ( EntityCode == postEntity && FiscalCode == postFiscalCode) { selObj.selectedIndex = optionCntr; } foundEntity = true; optionCntr++ } } } function getFirstEntity(name) { var firstEntityName = name; // document.write(firstEntityName); document.getElementById('firstEntityName').value = firstEntityName; } function populateEntity() { var selObj = document.getElementById('entityId'); var foundEntity = false; // Empty options just in case new drop down is shorter if ( selObj.type == 'select-one' ) { for (var i = 0; i < selObj.options.length; i++) { selObj.options[i] = null; } selObj.options.length=null; selObj.options[0] = new Option('--- Select Entity ---',''); selObj.selectedIndex = 0; } // Populate the drop down with Entitys from the selected GovLevel var EntityLineArray = Entity.split("|"); // Split into lines var optionCntr = 0; for (var loop = 0; loop < EntityLineArray.length; loop++) { lineArray = EntityLineArray[loop].split(":"); GovLevelCode = TrimString(lineArray[0]); EntityCode = TrimString(lineArray[1]); EntityName = TrimString(lineArray[2]); if (document.getElementById('govLevel').value == GovLevelCode && GovLevelCode != '' ) { // If it's a input element, change it to a select if ( selObj.type == 'text' ) { parentObj = document.getElementById('entityId').parentNode; parentObj.removeChild(selObj); var inputSel = document.createElement("SELECT"); inputSel.setAttribute("name","entityId"); inputSel.setAttribute("id","entityId"); parentObj.appendChild(inputSel) ; selObj = document.getElementById('entityId'); // selObj.options[0] = new Option('Select Entity',''); // selObj.selectedIndex = 0; } if ( EntityCode != '' ) { selObj.options[optionCntr] = new Option(EntityName, EntityCode); } // See if it's selected from a previous post if ( EntityCode == postEntity && GovLevelCode == postGovLevel ) { selObj.selectedIndex = optionCntr; var FirstEntity = EntityName; //Run the function getFirstEntity(FirstEntity); } foundEntity = true; optionCntr++ } } // If the GovLevel has no Entities, change the select to a text box if ( ! foundEntity ) { parentObj = document.getElementById('entityId').parentNode; parentObj.removeChild(selObj); // Create the Input Field var inputEl = document.createElement("INPUT"); inputEl.setAttribute("id", "entityId"); inputEl.setAttribute("type", "text"); // inputEl.setAttribute("name", "Entity"); inputEl.setAttribute("size", 1); // inputEl.setAttribute("style", "display:none;"); inputEl.setAttribute("value", postEntity); parentObj.appendChild(inputEl) ; } populateFiscalPeriod(); } function initGovLevel(GovLevel) { populateGovLevel(GovLevel); populateEntity(); populateFiscalPeriod(); } //-->