﻿function FillDependantDropDown(Sourceddl,targetddls){Sourceddl=document.getElementById(Sourceddl);if(Sourceddl.value!='-1'){var arrddl1=targetddls.split(';');if(arrddl1.length>0){for(var x=0;x<arrddl1.length;x++){var arrTableValues=arrddl1[x].split(',');var strTextField=arrTableValues[1].split(' ');var strTextcon='';var strActuallText='';if(strTextField.length>2){strTextcon=strTextField[0]+"+ ', ' +"+strTextField[1]+" as "+strTextField[3];strActuallText=strTextField[3]}else{strTextcon=arrTableValues[1]}var Response=GeneralAjax.FillDependantDropDown(strTextcon,arrTableValues[2],arrTableValues[3],' AND '+arrTableValues[4]+'='+Sourceddl.value,arrTableValues[5]);var Destinationddl=document.getElementById(arrTableValues[0]);Destinationddl.disabled=false;Destinationddl=removeAllOptions(Destinationddl);Destinationddl=AddDefaultValue(Destinationddl);var dt=Response.value;for(var count=0;count<dt.Rows.length;count++){var optn=document.createElement("OPTION");if(arrTableValues[1].indexOf(' as')==-1){var strtext='';if(arrTableValues[1].indexOf('.')>0){strtext=arrTableValues[1].substring(arrTableValues[1].indexOf('.')+1)}else{strtext=arrTableValues[1]}optn.text=dt.Rows[count][strtext]}else{optn.text=dt.Rows[count][strActuallText]}if(arrTableValues[2].indexOf('.')>0){var strval='';strval=arrTableValues[2].substring(arrTableValues[2].indexOf('.')+1);optn.value=parseInt(dt.Rows[count][strval])}else{optn.value=parseInt(dt.Rows[count][arrTableValues[2]])}Destinationddl.options.add(optn)}}}}else{var arrddl1=targetddls.split(';');if(arrddl1.length>0){for(var x=0;x<arrddl1.length;x++){var arrTableValues=arrddl1[x].split(',');var Destinationddl=document.getElementById(arrTableValues[0]);Destinationddl.disabled=true;Destinationddl.value=-1}}}}function removeAllOptions(selectbox){var i;for(i=selectbox.options.length-1;i>=0;i--){selectbox.remove(i)}return selectbox}function AddDefaultValue(selectbox){var optn1=document.createElement("OPTION");optn1.text="--Select--";optn1.value="-1";selectbox.options.add(optn1);return selectbox}function GetZipCodeNew(objtxtZip,objDDlCountry,objDDlState,objCity){var strZipCode=document.getElementById(objtxtZip).value;if(strZipCode==''){return true}var Response=clsGeneralAjax.GetCountryStateFromZip(strZipCode);var dt=Response.value;if(dt==null){return}if(dt.Rows.length>0){if(dt.Rows[0].strCity){document.getElementById(objCity).value=dt.Rows[0].strCity}if(dt.Rows[0].intCountryID){document.getElementById(objDDlCountry).value=dt.Rows[0].intCountryID}if(dt.Rows[0].intCountryID){removeAllOptions(document.getElementById(objDDlState));var dtStates=clsGeneralAjax.GetStatesFromCountry(dt.Rows[0].intCountryID);var dt1=dtStates.value;if(dt1.Rows.length>0){var optn1=document.createElement("OPTION");optn1.text='--Select--';optn1.value='';document.getElementById(objDDlState).options.add(optn1);for(var count=0;count<dt1.Rows.length;count++){var optn=document.createElement("OPTION");optn.text=dt1.Rows[count]['strState'];optn.value=dt1.Rows[count]['intStateID'];document.getElementById(objDDlState).options.add(optn)}}}if(dt.Rows[0].intStateID){document.getElementById(objDDlState).value=dt.Rows[0].intStateID}}}function clickButton(e,txtCityID,txtStateID,DDlCountryID){var txtCity=document.getElementById(txtCityID);if(txtCity.Value==''){return false}var evt=e?e:window.event;if(txtCity.value!=''){var str=clsGeneralAjax.GetStateFromCity(txtCity.value);if(str!=''){document.getElementById(txtStateID).value=str.value}return false}}function FillStateFromCountryNew(objDDlCountry,objDDlState){if(document.getElementById(objDDlCountry).value!='-1'){removeAllOptions(document.getElementById(objDDlState));var dtStates=clsGeneralAjax.GetStatesFromCountry(document.getElementById(objDDlCountry).value);var dt1=dtStates.value;if(dt1==null){return}if(dt1.Rows.length>0){var optn1=document.createElement("OPTION");optn1.text='--Select--';optn1.value='';document.getElementById(objDDlState).options.add(optn1);for(var count=0;count<dt1.Rows.length;count++){var optn=document.createElement("OPTION");optn.text=dt1.Rows[count]['strState'];optn.value=dt1.Rows[count]['intStateID'];document.getElementById(objDDlState).options.add(optn)}}}else{removeAllOptions(document.getElementById(objDDlState))}}
