0

What I am trying to do is pass an HTML Link attribute into a modal. This solution works great for me: Passing data to a bootstrap modal but rather than simply POST text data I would like for the data to be an HTML Link in full, just like this:

<a href="http://example.com">http://example.com</a>

(please note that the link is on purpose 'a link' as well)

At the moment this fiddle works very well (which is also taken from the previous StackOverFlow question) https://jsfiddle.net/k7FC2/ but I am unsure how to change this line to do what I am trying to achieve:

So I would like to change this Javascript line:

<input type="text" name="bookId" value=""/>

and I would like to change that so it 'echoes' the value of an HTML Link (which is hotlinked) rather than just the text data as illustrated in the fiddle...

Any ideas?

Thanks!!

Henry
  • 5,195
  • 7
  • 21
  • 34

1 Answers1

1

You will have something like this in the modal:

<a href="" id="myLink"></a>

Then you can use the Javascript code from jsFiddle that you have provided, changing this:

$('#my_modal').on('show.bs.modal', function(e) {
    var myURL = 'http://someurladdress';
    $(e.currentTarget).find('#myLink').prop('href', myURL);
});
CdB
  • 4,738
  • 7
  • 46
  • 69