Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

pass id to a tag href in modal(bootstrap)

hy, i want to pass my id to a tag href in my modal(bootstrap), for know i using this to past my id from my modal button :

        modal.find('#down').attr('href', function(i, href) {
            return href + div.data('id');
        });

this is my a tag:

  <a type="button" id="down" href="<?php echo base_url(); ?>/aprove/download/">Berkas</a>

this is my modal button:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

<a href="javascript:;" title="Lihat" data-id="<?php echo $q->id_project ?>"  data-toggle="modal" data-target="#lihat-data">                                                        <button data-toggle="modal" data-target="#ubah-data" class="btn btn-secondary"><i class="far fa-eye"></i></i></button>                                                  </a>

the problem its, every time i click the modal button, my a tag(href) will add previous id to the new one, like this:

first modal:

href="http://localhost/pe//aprove/download/4"

second modal:

href="http://localhost/pe//aprove/download/41"

i need to refresh the table to make it just get their own id

>Solution :

So do something like

<a type="button" id="down" data-href="<?php echo base_url(); ?>/aprove/download/">Berkas</a>

and read the data attribute

var anchor = modal.find('#down')
anchor.attr('href', anchor.data('href') + div.data('id'));
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading