1
I got the following foreach()
<? foreach($cidades as $valor){ ?>
<div class="listacidade"><a href="<? echo base_url("cidade/".$valor->idParametro."-".url_title($valor->parametro)); ?>"><img src="<? echo base_url(); ?>site/modules/entrada/images/<?=url_title($valor->parametro);?>.jpg" width="250" height="120" alt=""/></a></div>
<? } ?>
In it I already make the normal query of the database and display according to the list of cities, but I need to click on one of the cities, that I can pass the idParametro
somehow, it may even be in $_POST
or $_SESSION
... I just wouldn’t want you to show up at the URL.
I thought of using city/codity-naming but it doesn’t work, because of the module, then I would have to create a module for each city.
Passing only the id
would already be good.
It wouldn’t work because I have a picture in this DIV and I would need it to appear...
– Sr. André Baill
Then you can take the idParametro of your DIV using Javascript or jQuery, and do a function that sends this data to your controller using AJAX. ;)
– Bruno Barroso
That’s right Bruno, but how would you do it?
– Sr. André Baill
Dude, you can put in the element that will receive the click(div, link or img) the tag html data-idparameter="35" and with jquery take the value 35, example: var idparametro = $('element selector'). attr('data-idparameter'). Then make the ajax request by passing the idparameter you took to the controller, example: $.ajax({ type: "POST", date: { id_parametro:idparametro }, url: "rota_da_function_da_sua_controller", dataType: "html" });
– Bruno Barroso
It worked @Andrébaill?
– Bruno Barroso
No, I was able to elaborate differently, using Session
– Sr. André Baill
Legal @Andrébaill
– Bruno Barroso