Search code examples
htmlcodeigniterloadhref

Use <a name=""> in codeigniter


i try to use in legend. And when i click a button that will run the function, I want to load same page but the desired position.

In view i use:

<a name="#C1"> <legend>Adicionar produto/serviço: </legend> </a>

But which is what I call the "#C1"? In controller?

Thanks for help


Solution

  • What i understand from your question is that you want to run a controller method but you also want to specify the desired position of the page than try this

    <a href="<?php echo base_url();?>/controller/method/#contact"><label>Adicionar produto/serviço:</label></a>
    

    Where controller is the name of your controller and method is the name of your function and base_url() is what you defined in the application/config/config.php

    Than in the view file give the desired section id as id="contact"

    Assume you have the contact div in the footer give its id as contact

    <div id="contact"></div>
    

    And the page will scroll down to the contact section of the page once the link will be clicked