Configure a popup based on a hyperlink call

I have an html code that describes community members like "KS Lenscapes" and "Venky P G" which onclick calls a modal pop-up #visit

<div class="portfolio-info">
    <a href="#visit" id="ks" ><h3>K S Lenscapes</h3></a>
</div>

<div class="portfolio-info">
    <a href="#visit" id="vpg"><h3>Venky P G</h3></a>
</div>
Run codeHide result

This is the #visit code:

<div id="visit" class="modalDialog">
    <div>
	<a href="#close" title="Close" class="close">X</a><br><br>    	
        <div class="text-center">
            <p><a class="btn btn-primary btn-lg" href="#" id="ba">Book Appointment</a></p>
	</div>
    </div>
</div>
Run codeHide result

I need the Assign Book button #visit to find out from which anchor tag it is being requested, and send an email to the appropriate portfolio by taking his email from a file or database.

I do not know how to do this, please help me with this.

+4
source share
2 answers

HTML:

<a href="#visit" id="fpp" onclick="updatePopup(this.id);"><h3>Bar</h3></a>

JavaScript:

function updatePopup(id) {
    document.getElementById('ba').href = 'path/to/handler?id=' + id;
}

HTML , JavaScript " " .

URL-, . - , , , .

0

data

<div class="portfolio-info">
    <a href="#visit" id="ks" data-url="URL TO POST THE DATA"><h3>K S Lenscapes</h3></a>
</div>

<div class="portfolio-info">
    <a href="#visit" id="vpg" data-url="URL TO POST THE DATA"><h3>Venky P G</h3></a>
</div>

URL- href , .

$('selector').data('url')

0

Source: https://habr.com/ru/post/1606749/


All Articles