There's a pop-up div that I need to display. I have a form form1
, and a class data_class
which gets the necessary information from the database and display it in the pop-up div.
Partial code data_class
:
case "get_data":
//some variable declaration here
//some code here
//some query here
$exp = explode("|", $row['notes'], 2);
$pos = strpos($exp[0], ' ', 10); //limits word count
$lim = substr($exp[0],0,$pos);
$datas=$datas."<div style=' margin-top:5px; width: 100%;'>".$lim."<a class="btn" data-popup-open="popup-1" href=\"#\" onclick=''>test popup</a></div>";}
^this gives me an error:
Parse error: syntax error, unexpected 'popup' (T_STRING).
Pop-up div CSS in form1
:
<style>
.popup {
width:100%;
height:100%;
display:none;
position:fixed;
top:0px;
left:0px;
background:rgba(0,0,0,0.75);
}
.popup-inner {
max-width:300px;
width:90%;
padding:40px;
position:absolute;
top:50%;
left:50%;
-webkit-transform:translate(-50%, -50%);
transform:translate(-50%, -50%);
box-shadow:0px 2px 6px rgba(0,0,0,1);
border-radius:3px;
background:#fff;
}
.popup-close {
width:30px;
height:30px;
padding-top:4px;
display:inline-block;
position:absolute;
top:0px;
right:0px;
transition:ease 0.25s all;
-webkit-transform:translate(50%, -50%);
transform:translate(50%, -50%);
border-radius:1000px;
background:rgba(0,0,0,0.8);
font-family:Arial, Sans-Serif;
font-size:20px;
text-align:center;
line-height:100%;
color:#fff;
}
.popup-close:hover {
-webkit-transform:translate(50%, -50%) rotate(180deg);
transform:translate(50%, -50%) rotate(180deg);
background:rgba(0,0,0,1);
text-decoration:none;
}
</style>
HTML pop-up div in form1
:
<a class="btn" data-popup-open="popup-1" href="#">test popup</a>
<div class="popup" data-popup="popup-1">
<div class="popup-inner">
<h2>TITLE HERE</h2>
<p>this is a trial. display complete information here!</p>
<p><a data-popup-close="popup-1" href="#">Close</a></p>
<a class="popup-close" data-popup-close="popup-1" href="#">x</a>
</div>
</div>
Pop-up script in form1
:
$(function() {
//OPEN POPUP
$('[data-popup-open]').on('click', function(e) {
var targeted_popup_class = jQuery(this).attr('data-popup-open');
$('[data-popup="' + targeted_popup_class + '"]').fadeIn(350);
e.preventDefault();
});
//CLOSE POPUP
$('[data-popup-close]').on('click', function(e) {
var targeted_popup_class = jQuery(this).attr('data-popup-close');
$('[data-popup="' + targeted_popup_class + '"]').fadeOut(350);
e.preventDefault();
});
});
I can make it work if it's directly in form1
but how can I do this through data_class
? I figured I can't use the script in the data_class
so now I'm at a complete loss as to where to go from here. What's the best way to go about this? Thanks in advance!