const data = {
"MG": [{ "slug": "belo-horizonte", "nome": "Belo Horizonte", "num": 20 }],
"SP": [{ "slug": "sao-paulo", "nome": "São Paulo", "num": 20 }]
}
var selectState = document.querySelector('select[id=country');
// populate select with data structure
for (var key in data) {
selectState.options[selectState.options.length] = new Option(key, key)
}
let selectMunicipies = document.querySelector('select[id=state]');
let selectInputModule = document.querySelector('input[id=module]')
let fiscalModule = document.querySelector('select[id=fiscalModule]');
let isMinifundio = fiscalModule.options[fiscalModule.selectedIndex].value == 'minifundio' ? true : false;
let isSmallPropertie = fiscalModule.options[fiscalModule.selectedIndex].value == 'small_propertie' ? true : false;
let isMediumPropertie = fiscalModule.options[fiscalModule.selectedIndex].value == 'medium_propertie' ? true : false;
let isBigPropertie = fiscalModule.options[fiscalModule.selectedIndex].value == 'bigPropertie' ? true : false;
// populate select with data structure
for (var key of Object.keys(data)) {
for (var city of data[key]) {
selectMunicipies.options[selectMunicipies.options.length] = new Option(city.nome, city.slug)
$('#module').text('O valor do módulo fiscal da sua região é de ' + city.num);
}
}
//get value = num in the object (module of propertie)
//calculate area (ha) of rural property
//classify propertie
if (isMinifundio) {
var minifundio = city.num;
$('#module').val(minifundio);
$('#dimension').val(minifundio);
} else if (isBigPropertie) {
console.log(isBigPropertie, 'isBigPropertie')
var big_propertie = (city.num * 10)
$('#module').val(big_propertie);
$('#propertieClassification').text('grande propriedade rural (latifúndio');
}
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Fiddle Pages
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Get Fiddle Pages with PRO
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.