function optionSetChanged() // apply this function of change of country field
{
// on the base of country change cities
var _collection = getCollection();
var _selectedCity = null;
var _cityOptionset = Xrm.Page.ui.controls.get("city");
if (_cityOptionset != null)
_selectedCity = _cityOptionset.getAttribute().getValue();
var _cityOptions = _cityOptionset.getAttribute().getOptions();
var _selectedCountry = Xrm.Page.getAttribute("Country").getText();
// If Country is empty, then clear the City field.
if (_selectedCountry == "")
{
_cityOptionset.clearOptions();
}
else
{
for (var i = 0; i < _collection.length; i++)
{
if (_selectedCountry.toLowerCase() == _collection[i].Country.toLowerCase())
{ _
cityOptionset.clearOptions();
for (var j = 0; j < _collection[i].Cities.length; j++)
{
for (var k = 0; k < _cityOptions.length; k++)
{
if (_collection[i].Cities[j].toLowerCase() == _cityOptions[k].text.toLowerCase())
{
_cityOptionset.addOption(_cityOptions[k]);
break;
}
}
}
break;
}
}
if (_cityOptionset != null && _selectedCity != null)
_cityOptionset.getAttribute().setValue(_selectedCity);
}
}
function getCollection() {
var _collection = new Array();
var India_Cities = new Array("NewYork");
var India_obj = { Country: "USA", Cities: India_Cities };
_collection.push(India_obj);
var Srilanka_Cities = new Array("Lahore");
var SriLanka_obj = { Country: "pakistan", Cities: Srilanka_Cities };
_collection.push(SriLanka_obj);
var USA_Cities = new Array("Mumbai");
var USA_obj = { Country: "India", Cities: USA_Cities };
_collection.push(USA_obj);
return _collection;
}
{
// on the base of country change cities
var _collection = getCollection();
var _selectedCity = null;
var _cityOptionset = Xrm.Page.ui.controls.get("city");
if (_cityOptionset != null)
_selectedCity = _cityOptionset.getAttribute().getValue();
var _cityOptions = _cityOptionset.getAttribute().getOptions();
var _selectedCountry = Xrm.Page.getAttribute("Country").getText();
// If Country is empty, then clear the City field.
if (_selectedCountry == "")
{
_cityOptionset.clearOptions();
}
else
{
for (var i = 0; i < _collection.length; i++)
{
if (_selectedCountry.toLowerCase() == _collection[i].Country.toLowerCase())
{ _
cityOptionset.clearOptions();
for (var j = 0; j < _collection[i].Cities.length; j++)
{
for (var k = 0; k < _cityOptions.length; k++)
{
if (_collection[i].Cities[j].toLowerCase() == _cityOptions[k].text.toLowerCase())
{
_cityOptionset.addOption(_cityOptions[k]);
break;
}
}
}
break;
}
}
if (_cityOptionset != null && _selectedCity != null)
_cityOptionset.getAttribute().setValue(_selectedCity);
}
}
function getCollection() {
var _collection = new Array();
var India_Cities = new Array("NewYork");
var India_obj = { Country: "USA", Cities: India_Cities };
_collection.push(India_obj);
var Srilanka_Cities = new Array("Lahore");
var SriLanka_obj = { Country: "pakistan", Cities: Srilanka_Cities };
_collection.push(SriLanka_obj);
var USA_Cities = new Array("Mumbai");
var USA_obj = { Country: "India", Cities: USA_Cities };
_collection.push(USA_obj);
return _collection;
}
No comments:
Post a Comment