Reputation: 1196
i create popup javascript, for show school. But when i click link show popup, this popup position in behind, i already add z-index in css inline but does not work :'(
This is screenshot
This is my script..
<html>
<?php include "connection.php";?>
<script>
function profile(kode,logo,address,ket,name,status,phone)
{
var data =''+kode+'';
var h ='';
h +='<div style="background-color:#ffffff; z-index:9999999;" id="profilenya" >';
h +='<div style="background-color:#ffffff; z-index:9999999;">';
h +='<br/><h2 style="background-color:#359ace; width: auto;"><center>'+name+'</center></h2><br/>';
h +='<table><tr><td rowspan="2"> <img style="border:1px solid #369ace; padding: 5px 30px;" width="160px" height="160px" src="images/sekolah/logo/'+logo+'"></td>';
h +='<td> <i class="fa fa-home fa-2x"></i> <font color="black">'+address+'</td>';
h +='<tr><td> <i class="fa fa-phone fa-2x"></i> <font color="black">'+phone+'</td></tr>';
h +='<tr height="20px"><td></td><td></td></tr>';
h +='<tr><td><center style="border:1px solid #369ace; padding: 5px 3px;" >Klik Disini untuk mendukung <br/>agar sekolah ini menampilkan <br/>brosur online</center> </td>';
h +='<td><div style="border-radius: 3px; border:1px solid #369ace; padding: 5px 3px;"> <font color="black">Ket: <br/> '+ket+' </div></td></tr>';
h +='<tr height="10px"><td></td><td></td></tr>';
h +='</table>';
h +='<a href="#" id="closedialog" style="display:block; position:absolute; top:3px; right:2px; background:rgb(245,245,245); color:black; height:30px; width:35px; font-size:30px; text-decoration:none; text-align:center; font-weight:bold;">×</a>';
h +='</div>';
h +='</div>';
$('body').append(h);
$('#profilenya').dialog({
resizable: true,
width: 420,
height: 300,
position: {
my: 'center',
at: 'center',
of: window
},
modal: true
});
}
</script>
<?php
$data_school=mysql_query("select * from school");
$i=0;
while($school = mysql_fetch_object($data_school))
{
$i++
echo "".$i."<a onclick=\"profile('".$row['kode']."','".$row['logo']."','".$row['address']."','".$row['ket']."','".$row['name']."','".$row['status']."','".$row['phone']."');\" ><h4>".$row['name']."</h4></a>";
}
?>
</html>
And how to close popup in link (X). This code..
h +='<a href="#" id="closedialog" style="display:block; position:absolute; top:3px; right:2px; background:rgb(245,245,245); color:black; height:30px; width:35px; font-size:30px; text-decoration:none; text-align:center; font-weight:bold;">×</a>';
Help me.. pliss
Upvotes: 0
Views: 637
Reputation: 5926
I've created a very basic fiddle of the things I explained in the comments:
The HTML
<div id="main">
<button type="button" id="clck" onclick="javascript:popup();">Clicky?</button>
</div>
<div id="alertContainer">
<div id="alertContent">
<p>
I fight dragons with tooth picks. Rawrr!
</p>
<span id="close">×</span>
</div>
</div>
And Javascript:
var popupBox = document.getElementById('alertContainer');
var x = document.getElementById('close');
function popup(){
popupBox.className = popupBox.className + 'show';
}
$('#close').click(function() {
popupBox.className = "";
});
There's also plugins like SweetAlert available.
ps I didn't use pure javascript - the close buttons click is with jQuery (so you'd have to import that in your HTML file's header)
Upvotes: 1