I am trying to pass the value of the Company_ID in my select from my href, but to no avail. Can someone give me an address please? This is my href:
<div class="box-footer clearfix">
<a href="<?=site_url('dashboard/financeiros/excelFinanceiro?empresa=[document.getElementById("empresa").value]')?>" class="btn btn-sm bg-blackzag btn-flat pull-left">Gerar Excel</a>
</div>
I'm trying to capture the id of the company that's in this View. It is stated in some points.
<h4>FILTRAR:</h4>
</div>
<div class="col-lg-3 col-xs-12">
<div class="form-group">
<select class="form-control select2" id="empresa" style="width: 100%;" onchange="funcFiltra(1);">
<option value="0" selected="selected">Empresa</option>
<?php foreach($empresas as $v):?>
<option value="<?=$v->getEmpresasId()?>"><?=$v->getNome()?></option>
<?php endforeach;?>
<option value="0">Todos</option>
</select>
</div>
</div>
And it has this function that makes the filter:
<script>
funcCarregaCombo();
function funcCarregaCombo() {
document.getElementById("empresa").value = <?php echo $_SESSION['ID_EMPRESA']; ?>;
}
function funcFiltra(opcao) {
var idItem = opcao;
var idIndex = "";
switch(opcao) {
case 1:
idIndex = document.getElementById("empresa").value;
break;
case 2:
idIndex = document.getElementById("data").selectedIndex;
// Selecionado TODOS - ComboBox Tempo
if (idIndex == 0) {
location.href = site_url+'dashboard/financeiros/relatorio/';
}
break;
default:
break;
}
//alert("idItem = " + idItem);
//alert("idIndex = " + idIndex);
if ((idItem != null) || (idItem != "")) {
location.href = site_url+'dashboard/financeiros/filtro/'+idItem+'/'+idIndex;
}
}
</script>