Diasline
Diasline

Reputation: 635

Use anchor in link codeigniter

How can put an anchor to go to the section2 of a page onchange dropdwon list I use codeigniter ?

Dropdown

<select id="id_doc">
<option value=""></option>
<option value="1">Value1</option>
<option value="2">Value2</option>
</select>

Jquery

$("#id_doc").change(function(){

var id_doc= $(this).val();
 window.location.href="<?php echo base_url('admin/page2'); ?>?id_doc="+id_doc;

});

page2

   <div id="section1"></div> 
   <div id="section2"></div> 

Upvotes: 1

Views: 836

Answers (1)

Abdulla Nilam
Abdulla Nilam

Reputation: 38584

normally this will call the div in URL

<?php echo base_url('admin/page2'); ?>#section1

In JS follow the same thing

window.location.href="<?php echo base_url('admin/page2'); ?>"+id_doc;

or with <a> tag

<a href="<?php echo base_url('admin/page2'); ?>#section1">Go Section 01</a>
<a href="<?php echo base_url('admin/page2'); ?>#section2">Go Section 02</a>

Example

https://stackoverflow.com/users/4595675/abdulla-nilam?tab=profile#top-tags

and this in code

<div id="top-tags" class="top-tags content-element">

Read - What is the meaning of # in URL and how can i use that?

Upvotes: 1

Related Questions