Jump to content

pop up window


nicedad

Recommended Posts

Hi everyone,

 

I created a database table that includes a link to CV's (see attached image). I need the following action to be done;

if someone clicks on the link to any CV, he gets a pop-up window notifying a message to contact the Admin.

 

Here is a snapshot of the code

?>
<tr>
    <td><?php echo $userList[$i]["name"]; ?></td>
    <td><?php echo $userList[$i]["about_me"]; ?></td>
    <td><?php echo $userList[$i]["date_of_birth"]; ?></td>    
    <td><?php echo $userList[$i]["country_origin"]; ?></td>
    <td><?php echo $userList[$i]["permit"]; ?></td>
    <td><?php echo $userList[$i]["contact"]; ?></td>
    <td><?php echo $userList[$i]["city"]; ?></td>
    <td><?php echo $userList[$i]["occupation"]; ?></td>
    <?php if ($_SESSION['type_of_logged_in_user'] == "company") { ?>
    <td><a href="<?php echo $userList[$i]["cv_path"]; ?>">Download</a></td>
    <?php } else { ?>
    <td><a class="login_first_messg" href="#">Download</a></td>
    <?php } ?>
</tr>
<?php
        }
    }//for close
?>
        </table>
        </div>
        </div>

post-179690-0-89402000-1448008502_thumb.jpg

Link to comment
Share on other sites

PHP can not create popups you will need to use JavaScript. First add a class to your cv links, example

<a href="<?php echo $userList[$i]["cv_path"]; ?>" class="cv-download">

Now in javascript apply a click event handler to all elements that contain the cv-download class

<script>
window.onload = function() {
    // this function is called by the onclick event handler
    function notify(e) {
        // use this to prevent the link from working
        e.preventDefault();

        // show an alert
        alert("Please contact admin to download CV's");
    }
    // attach onclick event handler to all links with class cv-download
    links = document.getElementsByClassName('cv-download');
    for(i = 0; i < links.length; i++ ) {
        links[i].addEventListener('click', notify);
    }
}
</script>
Link to comment
Share on other sites

should the class be in the body?

No, I said add that class to you cv download links.

 

 

is the java script a stand alone file or within the PHP code?

If you want to have it in an external javascript file, then first remove the <script></script> tag from my code, then save the code in a new file, name it notify.js (or whatever you want to name it).

You will then link to the file using the following in the your HTML <head> tag

<script src="notify.js"></script>

Otherwise just place the code I posted within the <head></head> tags

Link to comment
Share on other sites

Hellon Ch0cu3r

 

I added the code you suggested in it's place unfortunately has no effect, therefore I post the entire code to see whether I did a mistake or not.
please notice that the code was proposed to enable logged user (companies) to download any CV. plase see end od code.

<!DOCTYPE html>
<html lang="en">
  <head>
    	<style>
	.btnjoin {
		padding: 5px 20px;
		border-radius: 4px;
		margin-bottom: 10px;
		color: #F0F8FF;
		background-color: #3CB6CB;
		border: none;
		cursor: pointer;
	}
	
	    
    .table-striped>tbody>tr:nth-child(odd)>td,
.table-striped>tbody>tr:nth-child(odd)>th {
	background-color: #DDDDDD;
}

.table-striped>tbody>tr:nth-child(odd)>th {/*table header color*/
	
	background-color: #3CB6CB; /*it was #bbb*/
}

.space5 {
    margin-top: 5px;
}
body {
    background-color: #F3FFF3;
}

	</style>
    
    <script>
window.onload = function() {
     function notify(e) {
         e.preventDefault();
        alert("Please contact admin to download CV's");
    }
    links = document.getElementsByClassName('cv-download');
    for(i = 0; i < links.length; i++ ) {
        links[i].addEventListener('click', notify);
    }
}
</script>
    
	
  </head>

  <body>

    <div id="container" class="container">

<a href="http://www.templatemo.com/preview/templatemo_382_simplex" rel="nofollow">
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" 
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" 
width="468" height="60"
<param name="movie" value="banner.swf"<param name="quality" value="high" /><param name="bgcolor" value="#ffffff"/>
		<embed src="banner.swf" quality="high" bgcolor="#ffffff" width="1140" height="300"
name="banner" align="" type="application/x-shockwave-flash"
pluginspage="http://www.macromedia.com/go/getflashplayer">
</embed></object>
</a>
        
<ul class="nav nav-justified">
  <ul class="nav nav-justified">
  <li class=""><a href="index.html">Home</a></li>
  <li><a href="aboutus.html">Über Uns</a></li>
  <li><a href="service.html">Service</a></li>
  <li><a href="datenbank.php">Datenbank</a></li>
  <li><a href="jobs.html">Jobs</a></li>
  <li><a href="kontakt.html">Contact</a></li>
</ul>

  <div class="row space30"> <!-- row 1 begins -->      
	<div class="col-md-12">
    
    		<a href="login.php" class="btnjoin  pull-right" style="padding:5px 29px;margin-right:10px;">Login/ Anmelden</a>
        		<a href="jobs.php" class="btnjoin  pull-right" style="padding:5px 29px;margin-right:10px;">Jobs</a>
                  <a href="datenbank.php" class="btnjoin  pull-right" style="padding:5px 29px;margin-right:10px;">Bewerber</a>

<?php if(!empty($userList["total_records"])) { ?>
	<div class="left"> <span style="color: #240CF7"><strong>
	<?php echo $userList["total_records"]; ?></strong></span> <span style="color: #0E3CEF; font-size: 14px;">Bewerber verfügbar 
    
    </span></div>
<?php } ?>


<form method="post">
<div class="row space30"> <!-- row 2 begins -->
	<div  class="col-md-12 text-center">
    	<?php
	$userCity = $objUser->getCity();
	?>
	<select name="search[city]" style="min-width: 150px;padding: 3px;margin-right:25px;">
	<option value="">Kanton auswählen</option>
	<?php
	if(!empty($userCity)) {
	foreach($userCity as $k=>$v) {
	?>
<option value="<?php echo $userCity[$k]["city"]; ?>" 
<?php if($userCity[$k]["city"] == $city) { echo "selected"; } ?>>
<?php echo $userCity[$k]["city"]; ?></option>
	<?php	
	}
	}
	?>
	</select>
	<?php
	$userOccupation = $objUser->getOccupation();
	?>
	<select name="search[occupation]" style="min-width: 150px;padding: 3px;">
	<option value="">Beruf auswählen</option>
	<?php
	if(!empty($userOccupation)) {
	foreach($userOccupation as $k=>$v) {
	?>
	<option value="<?php echo $userOccupation[$k]["occupation"]; ?>" <?php if($userOccupation[$k]["occupation"] == $occupation) { echo "selected"; } ?>>
	<?php echo $userOccupation[$k]["occupation"]; ?></option>
	<?php	
	}
	}
	?>
	</select>
	<input type="submit" name="go" value="Search" style="border-color: none;border: 2px outset buttonface;padding: 2px 45px;margin-left: 20px;" >
	<input type="reset" value="Reset" style="border-color: none;border: 2px outset buttonface;padding: 2px 45px;margin-left: 10px;" 
    onclick="window.location='datenbank.php'">
	</div>
</div>
<?php
if(!empty($userList)) {
?>
      	<div class="row space5"> <!-- row 3 begins -->
		<div  class="col-md-12">
            <table class="table table-striped">
			<tr>
			<th style="width: 14%;">Person</th>
			<th style="width: 14%;">About Me</th>
			<th style="width: 8%;">Geburtstag</th>
			<th style="width: 12%;">Staadsangehörigkeit</th>
			<th style="width: 10%;">Aufenthalt</th>
			<th style="width: 12%;">Kontakt</th>
			<th style="width: 10%;">Kanton</th>
			<th style="width: 12%;">Berufswunsch</th>
			<th style="width: 8%;">Lebenslauf</th>
			</tr>
<?php

    foreach($userList as $i => $value) {
		if(is_numeric($i)) {
?>
<tr>
    <td><?php echo $userList[$i]["name"]; ?></td>
	<td><?php echo $userList[$i]["about_me"]; ?></td>
    <td><?php echo $userList[$i]["date_of_birth"]; ?></td>	
    <td><?php echo $userList[$i]["country_origin"]; ?></td>
	<td><?php echo $userList[$i]["permit"]; ?></td>
	<td><?php echo $userList[$i]["contact"]; ?></td>
	<td><?php echo $userList[$i]["city"]; ?></td>
	<td><?php echo $userList[$i]["occupation"]; ?></td>
    
	<?php if ($_SESSION['type_of_logged_in_user'] == "company") { ?>
	<!--<td><a href="<?php echo $userList[$i]["cv_path"]; ?>">Download</a></td> -->
    
    <td><a href="<?php echo $userList[$i]["cv_path"]; ?>" class="cv-download"></td>
	<?php } else { ?>
	<td><a class="login_first_messg" href="#">Download</a></td>
	<?php } ?>
</tr>
<?php
		}
	}//for close
?>
		</table>
		</div>
		</div>


<?php if(!empty($userList["perpage"])) { ?>
	<div class="pagination center"><?php echo $userList["perpage"]; ?></div>
<?php } ?>
<?php
}//if close
?>
</form>

      
      <!-- Site footer -->
      <div class="footer">
        <p></div><div class="footer"><p><center>© Copyright 2015 | Ausländer und Integrations Dienste | <a rel="nofollow" href="http://www.a-Integrationsdienste.ch">www.a-Integrationsdienste.ch</a></center>
               </div>
<div id="login-first-messg-modal" class="modal fade" role="dialog">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">×</button>
      </div>
      <div class="modal-body">
	  	You have to <a href="login.php">login</a> first as Employer on this site to download C.V.
      </div>
    </div>
  </div>
</div>
	<script type="text/javascript">
	$('.login_first_messg').on('click', function(e) {
		$("#login-first-messg-modal").modal({});
		e.preventDefault();
	});
	
	</script>
  </body>
</html>
Link to comment
Share on other sites

Yeah I tried it with it and I removed it only to test the code.

still not working!

you can test it online under this link.

 

http://a-integrationsdienste.ch/datenbank.php

<?php
session_start();
require_once("common/DAO.php");
require_once("./common/config.php");
require_once("classes/class.users.php");
require_once("services/MemberService.php");

$objUser = new User();  
$city = "";
$occupation = "";

$searchCondition = "";
if(!empty($_POST["search"])) {
	foreach($_POST["search"] as $k=>$v){
		if(!empty($v)) {
			$queryCases = array("city","occupation");
			if(in_array($k,$queryCases)) {
				$searchCondition .= " AND ";						
			}
			switch($k) {
				case "city":
					$city = $v;
					$searchCondition .= "city LIKE '" . $v . "%'";
					break;
				case "occupation":
					$occupation = $v;
					$searchCondition .= "occupation LIKE '" . $v . "%'";
					break;
			}
		}
	}
}              
$userList = $objUser->getMember($searchCondition);
?>
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Integrationsdienste</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />	
    <meta name="description" content="">
    <meta name="author" content="templatemo">
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="css/templatemo_justified.css" rel="stylesheet">
	<script type="text/javascript" src="js/jquery/jquery-1.9.1.js"></script>
	<script type="text/javascript" src="js/bootstrap.js"></script>
    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="js/html5shiv.js"></script>
      <script src="js/respond.min.js"></script>
    <![endif]-->
	<style>
	.btnjoin {
		padding: 5px 20px;
		border-radius: 4px;
		margin-bottom: 10px;
		color: #F0F8FF;
		background-color: #3CB6CB;
		border: none;
		cursor: pointer;
	}
	
	    
    .table-striped>tbody>tr:nth-child(odd)>td,
.table-striped>tbody>tr:nth-child(odd)>th {
	background-color: #DDDDDD;
}

.table-striped>tbody>tr:nth-child(odd)>th {/*table header color*/
	
	background-color: #3CB6CB; /*it was #bbb*/
}

.space5 {
    margin-top: 5px;
}
body {
    background-color: #F3FFF3;
}

	</style>
    
    <script>
window.onload = function() {
     function notify(e) {
         e.preventDefault();
        alert("Please contact admin to download CV's");
    }
    links = document.getElementsByClassName('cv-download');
    for(i = 0; i < links.length; i++ ) {
        links[i].addEventListener('click', notify);
    }
}
</script>
    
	
  </head>

  <body>

    <div id="container" class="container">

<a href="http://www.templatemo.com/preview/templatemo_382_simplex" rel="nofollow">
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" 
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" 
width="468" height="60"
<param name="movie" value="banner.swf"<param name="quality" value="high" /><param name="bgcolor" value="#ffffff"/>
		<embed src="banner.swf" quality="high" bgcolor="#ffffff" width="1140" height="300"
name="banner" align="" type="application/x-shockwave-flash"
pluginspage="http://www.macromedia.com/go/getflashplayer">
</embed></object>
</a>
        
<ul class="nav nav-justified">
  <ul class="nav nav-justified">
  <li class=""><a href="index.html">Home</a></li>
  <li><a href="aboutus.html">Über Uns</a></li>
  <li><a href="service.html">Service</a></li>
  <li><a href="datenbank.php">Datenbank</a></li>
  <li><a href="jobs.html">Jobs</a></li>
  <li><a href="kontakt.html">Contact</a></li>
</ul>

  <div class="row space30"> <!-- row 1 begins -->      
	<div class="col-md-12">
    
    		<a href="login.php" class="btnjoin  pull-right" style="padding:5px 29px;margin-right:10px;">Login/ Anmelden</a>
        		<a href="jobs.php" class="btnjoin  pull-right" style="padding:5px 29px;margin-right:10px;">Jobs</a>
                  <a href="datenbank.php" class="btnjoin  pull-right" style="padding:5px 29px;margin-right:10px;">Bewerber</a>

<?php if(!empty($userList["total_records"])) { ?>
	<div class="left"> <span style="color: #240CF7"><strong>
	<?php echo $userList["total_records"]; ?></strong></span> <span style="color: #0E3CEF; font-size: 14px;">Bewerber verfügbar 
    
    </span></div>
<?php } ?>


<form method="post">
<div class="row space30"> <!-- row 2 begins -->
	<div  class="col-md-12 text-center">
    	<?php
	$userCity = $objUser->getCity();
	?>
	<select name="search[city]" style="min-width: 150px;padding: 3px;margin-right:25px;">
	<option value="">Kanton auswählen</option>
	<?php
	if(!empty($userCity)) {
	foreach($userCity as $k=>$v) {
	?>
<option value="<?php echo $userCity[$k]["city"]; ?>" 
<?php if($userCity[$k]["city"] == $city) { echo "selected"; } ?>>
<?php echo $userCity[$k]["city"]; ?></option>
	<?php	
	}
	}
	?>
	</select>
	<?php
	$userOccupation = $objUser->getOccupation();
	?>
	<select name="search[occupation]" style="min-width: 150px;padding: 3px;">
	<option value="">Beruf auswählen</option>
	<?php
	if(!empty($userOccupation)) {
	foreach($userOccupation as $k=>$v) {
	?>
	<option value="<?php echo $userOccupation[$k]["occupation"]; ?>" <?php if($userOccupation[$k]["occupation"] == $occupation) { echo "selected"; } ?>>
	<?php echo $userOccupation[$k]["occupation"]; ?></option>
	<?php	
	}
	}
	?>
	</select>
	<input type="submit" name="go" value="Search" style="border-color: none;border: 2px outset buttonface;padding: 2px 45px;margin-left: 20px;" >
	<input type="reset" value="Reset" style="border-color: none;border: 2px outset buttonface;padding: 2px 45px;margin-left: 10px;" 
    onclick="window.location='datenbank.php'">
	</div>
</div>
<?php
if(!empty($userList)) {
?>
      	<div class="row space5"> <!-- row 3 begins -->
		<div  class="col-md-12">
            <table class="table table-striped">
			<tr>
			<th style="width: 14%;">Person</th>
			<th style="width: 14%;">About Me</th>
			<th style="width: 8%;">Geburtstag</th>
			<th style="width: 12%;">Staadsangehörigkeit</th>
			<th style="width: 10%;">Aufenthalt</th>
			<th style="width: 12%;">Kontakt</th>
			<th style="width: 10%;">Kanton</th>
			<th style="width: 12%;">Berufswunsch</th>
			<th style="width: 8%;">Lebenslauf</th>
			</tr>
<?php

    foreach($userList as $i => $value) {
		if(is_numeric($i)) {
?>
<tr>
    <td><?php echo $userList[$i]["name"]; ?></td>
	<td><?php echo $userList[$i]["about_me"]; ?></td>
    <td><?php echo $userList[$i]["date_of_birth"]; ?></td>	
    <td><?php echo $userList[$i]["country_origin"]; ?></td>
	<td><?php echo $userList[$i]["permit"]; ?></td>
	<td><?php echo $userList[$i]["contact"]; ?></td>
	<td><?php echo $userList[$i]["city"]; ?></td>
	<td><?php echo $userList[$i]["occupation"]; ?></td>
    
	<?php if ($_SESSION['type_of_logged_in_user'] == "company") { ?>
	<td><a href="<?php echo $userList[$i]["cv_path"]; ?>" class="cv-download">Download</a></td>
    
    <td><a href="<?php echo $userList[$i]["cv_path"]; ?>" class="cv-download"></td>
	<?php } else { ?>
	<td><a class="login_first_messg" href="#">Download</a></td>
	<?php } ?>
</tr>
<?php
		}
	}//for close
?>
		</table>
		</div>
		</div>


<?php if(!empty($userList["perpage"])) { ?>
	<div class="pagination center"><?php echo $userList["perpage"]; ?></div>
<?php } ?>
<?php
}//if close
?>
</form>

      
      <!-- Site footer -->
      <div class="footer">
        <p></div><div class="footer"><p><center>© Copyright 2015 | Ausländer und Integrations Dienste | <a rel="nofollow" href="http://www.a-Integrationsdienste.ch">www.a-Integrationsdienste.ch</a></center>
               </div>

    </div> <!-- /container -->

    <!-- Bootstrap core JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    </ul>


  </body>
</html>
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.