Get value of TD where Checkbox is checked in table - javascript

This is the code, im trying to get the value of each TD with id=tel2 and checkbox is checked and store all values in textarea separated with Comma ','
Any suggestion ?
echo "<div>";
if ($result->num_rows > 0) {
echo "<table border='1' cellpadding='10'>";
echo "<tr> <th></th> <th>Nom</th> <th>Prenom</th> <th>Tel</th> <th>Classe</th> <th>Annee</th> </tr>";
while($row = $result->fetch_assoc()) {
echo "<tr>";
echo "<td> <input type=\"checkbox\" id=\"case\"></td>";
echo "<td>" . $row['nom'] . "</td>";
echo "<td>" . $row['prenom'] . "</td>";
echo "<td id=\"tel2\">" . $row['tel'] . "</td>";
echo "<td>" . $row['classe'] . "</td>";
echo "<td>" . $row['annee'] . "</td>";
echo "</tr>";
}
echo "</table>";
}
echo "</div>";
?>

Related

How to generate ids for tables made by php

I am trying to create a page to allow toggling on and off certain forums in website, created from raw data in an SQL server. However I need each to have an individual ID so I can show/hide them based on user preference. I am not sure how to go about it. Here is my existing code, disregard the connection values, I am hiding them on purpose. thanks.
$db_host = "host";
$db_username = "username";
$db_pass = "pass";
$db_name = "name";
$db = new PDO('mysql:host='.$db_host.';dbname='.$db_name,$db_username,$db_pass);
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
$query = $db->query('SELECT p.name, p.company, o.prodtype AS Type
FROM ownedproducts AS o
JOIN product as p ON p.productID = o.productID
WHERE o.usersID = 2');
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css" />
<title> User Forum Selection </title>
</head>
<body>
<div>
<input type="text" id="userid">
</div>
<div>
<hr>
<table id=table border = '2'>
<tr id=table-row>
<th id=table-header>Name</th>
<th id=table-header>Company</th>
<th id=table-header>Type</th>
</tr>
<?php
while ($row = $query->fetch())
{
echo "<tr id=table-row >";
echo "<td>" . $row['name'] ."</td>";
echo "<td>" . $row['company'] . "</td>";
echo "<td>" . $row['Type'] . "</td>";
echo "</tr>";
}
?>
</table>
</div>
</body>
</html>
What about using the product id ? That sounds logical here.
Select it :
$query = $db->query('SELECT p.productID, p.name, p.company, o.prodtype AS Type ...
Then use it in your rows :
while ($row = $query->fetch())
{
echo "<tr id='table-row-" . $row['id'] . "' >";
echo "<td>" . $row['name'] ."</td>";
echo "<td>" . $row['company'] . "</td>";
echo "<td>" . $row['Type'] . "</td>";
echo "</tr>";
}
Always use single and double quote in id as (id=' ', id=" ")
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css" />
<title> User Forum Selection </title>
</head>
<body>
<div>
<input type="text" id="userid">
</div>
<div>
<hr>
<table id=table border = '2'>
<tr id=table-row>
<th id=table-header>Name</th>
<th id=table-header>Company</th>
<th id=table-header>Type</th>
</tr>
<?php
while ($row = $query->fetch())
{
echo "<tr id=table-row >";
echo "<td>" . $row['name'] ."</td>";
echo "<td>" . $row['company'] . "</td>";
echo "<td>" . $row['Type'] . "</td>";
echo "</tr>";
}
?>
</table>
</div>
</body>
</html>
use it in your rows :
<?php
foreach( $query->fetch() as $rows=> $row)
{
echo "<tr id='table-row-'.$rows >";
echo "<td>" . $row[or</td>";
echo "<td>" . $row['company'] . "</td>";
echo "<td>" . $row['Type'] . "</td>";
echo "</tr>";
}
?>
I'd probably do it in a foreach and use the key.
foreach( $query->fetch() as $key => $row)
{
echo "<tr id='table-row-'.$key >";
echo "<td>" . $row['name'] ."</td>";
echo "<td>" . $row['company'] . "</td>";
echo "<td>" . $row['Type'] . "</td>";
echo "</tr>";
}

Column value not updated in the table

I am not able to update one column field. Please Suggest me what is the wrong thing in my code
index.php
<?php
$host = "localhost";
$user = "root";
$pass = "";
$db_name = "logistics";
$lastId="";
//create connection
$con = mysqli_connect($host, $user, $pass, $db_name);
$result = mysqli_query($con,"SELECT * FROM notification");
?>
<div class="table-inner-wrapper">
<h5 class="text- blll"> Active Alerts </h5>
<table class="table table-hover table-striped">
<tr class="t_head">
<th>ID </th>
<th>Forklift ID</th>
<th>Timestamp</th>
<th>Duration</th>
<th>Alert Details</th>
<th></th>
<th>Remark</th>
<th></th>
</tr>
<?php
while($row = mysqli_fetch_array($result)){
echo "<form action='' id='remarks' method='post'>";
echo "<tr>";
echo "<td>" . $row['id'] . "</td>";
echo "<td>" . $row['forklift_id'] . "</td>";
echo "<td>" . $row['noti_start'] . "</td>";
echo "<td>" . $row['duration'] . " hr</td>";
echo "<td>" . $row['alert_details'] . "</td>";
echo "<td><i class='email' id='". $row['id'] ."'> <i class='fa fa-inbox fa-2x'> </i> </i> </td>";
echo "<td><textarea class='remarks' id='".$row['id']."'> ".$row['remarks']." </textarea></td>";
echo "<td><input type='button' class='btn btn-info remark' value='submit' id='".$row['id']."'></td>";
echo "</tr>";
echo "</form>";
}
?>
</table>
</div>
<script type="text/javascript">
$(() => {
$(document).ready(function(){
$(".remark").on('click',function(e){
e.preventDefault();
var id = $(this).attr('id');
var remarks = $("textarea.remarks").val();
// alert(remarks);
// alert(id);
$.ajax({
url:'remark.php',
method:'POST',
data: {id: id, remarks: remarks},
success:function(data){
alert(data);
// return data;
}
});
});
});
})
</script>
remark.php
<?php
$conn = new mysqli('localhost', 'root', '', 'logistics');
$remarks = $_POST['remarks'];
echo $remarks;
$id = $_REQUEST['id'];
echo $id;
$sql = "UPDATE notification SET remarks='".$remarks."' WHERE id='".$id."' " ;
if($conn->query($sql)===TRUE){
echo "DATA updated";
}
?>
I am trying to update remarks column value on submit based on row id but it's updating only a first row of column value and if i click on the remaining rows it is not updating the remarks value.
A couple things:
I would change $id = $_REQUEST['id']; to $id = $_POST['id'];
Secondly, your <form> tag is inside your while loop which means you are echoing out a new form on every iteration. All of the forms will have the same id. This will cause you problems and fits the type of behavior that you are describing. Remove the <form> tags from the inside of the loop like so:
echo "<form action='' id='remarks' method='post'>";
while($row = mysqli_fetch_array($result)){
echo "<tr>";
echo "<td>" . $row['id'] . "</td>";
echo "<td>" . $row['forklift_id'] . "</td>";
echo "<td>" . $row['noti_start'] . "</td>";
echo "<td>" . $row['duration'] . " hr</td>";
echo "<td>" . $row['alert_details'] . "</td>";
echo "<td><i class='email' id='". $row['id'] ."'> <i class='fa fa-inbox fa-2x'> </i> </i> </td>";
echo "<td><textarea class='remarks' id='".$row['id']."'> ".$row['remarks']." </textarea></td>";
echo "<td><input type='button' class='btn btn-info remark' value='submit' id='".$row['id']."'></td>";
echo "</tr>";
}
echo "</form>";
This line:
var remarks = $("textarea.remarks").val();
will only give you the value of the first textarea with the class remarks. You need to access the remarks from the textarea associated with the button instead. You do have a problem though that you have multiple elements with the same id, so you need to fix that first. Try changing this code:
echo "<td><i class='email' id='". $row['id'] ."'> <i class='fa fa-inbox fa-2x'> </i> </i> </td>";
echo "<td><textarea class='remarks' id='".$row['id']."'> ".$row['remarks']." </textarea></td>";
to
echo "<td><i class='email' id='e". $row['id'] ."'> <i class='fa fa-inbox fa-2x'> </i> </i> </td>";
echo "<td><textarea class='remarks' id='t".$row['id']."'> ".$row['remarks']." </textarea></td>";
Now your textarea field has a unique id which is still related to $row['id']. So in your event code, you can write:
var remarks = $("#t" + id).val();
to get the value of remarks associated with that button.

how to disable checkbox after due date has passed

I've this code in php, and it retrieve all the value I've in my database, and I want the user not be able to choose or tamper with the one that has expired date,
please can you help me ?
my code below only show u the word 'Expired' and 'Not Expired' on the web, since I'm only Echoing it.
I want to just disable the check box, and not let the user be able to change anything like the statues or remove the job.
please can you help me ?
$result = mysqli_query($dbCIE,$sqlCommand) or die(mysql_error());
echo "<form action='JobsLists.php' method='post'>";
while($row = mysqli_fetch_array($result))
{
$exp_date = $row['DueDate'];
$today_date = date('Y/m/d');
$exp=strtotime($exp_date);
$td=strtotime($today_date );
if($td>$exp){
echo"Expiered";
}else{
echo"NOT Expiered";
}
echo "<tr>";
echo "<td> <input type='checkbox' id='myCheck' name='JobId[]' value='". $row['JobId'] ."' /> </td>";
echo "<td align=center>" . $row['SSU'] . "</td>";
echo "<td align=center>" . $row['JobName'] . "</td>";
echo "<td align=center> " . $row['Description'] . "</td>";
echo "<td align=center>" . $row['DueDate'] . "</td>";
echo "<td>"."<select name='JobStatus[".$row['JobId']."]'>";
if($row['JobStatus'] == "InProgress"){
echo "<option value='InProgress' selected>In Progress</option>";
echo "<option value='Completed'>Completed</option>";
} else {
echo "<option value='InProgress'>In Progress</option>";
echo "<option value='Completed' selected> Completed </option>";
}
echo "</select>" . "</td>"; // need to be worked on..
echo "</tr>";
}
"</table>";
?>
Why not just not print it out?
if (!$td->exp)
echo "<td> <input type='checkbox' id='myCheck' name='JobId[]' value='". $row['JobId'] ."' /> </td>";
It's better to just not show a button or input than to disable it sometimes. Inputs can be disabled with the DISABLED keyword
<input type="checkbox" name="foo" DISABLED>

How to display another table by clicking a button that is inside the table?

<html>
<body>
<form action="index.php" method="post">
<input type="text" name="search" placeholder="Search for members..." />
<input type="submit" value="search" />
</form>
</body>
</html>
<html>
<head>
<style>
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
th, td {
padding: 5px;
text-align: middle;
}
</style>
<script type="text/javascript">
function showHide(id) {
if (document.getElementById(id).style.display == 'none') {
document.getElementById(id).style.display = '';
}
else {
document.getElementById(id).style.display = 'none';
}
}
</script>
</head>
<body>
<table border="1">
<?php
mysql_connect("localhost","root","") or die("could not connect");
mysql_select_db("vauban") or die("could not find database");
$output = '';
if(isset($_POST['search'])) {
$searchq = $_POST['search'];
$searchq = preg_replace("#[^0-9a-z]#i","",$searchq);
$query = mysql_query("SELECT * FROM info3 WHERE FirstName LIKE '%$searchq%' OR LastName LIKE '%$searchq%'") or die("could not search!");
$count = mysql_num_rows($query);
if($count == 0) {
$output = 'There was no search results!';
}else{
while($row = mysql_fetch_array($query)) {
$id = $row['Id'];
echo"<td>". $row['Id']."</td>";
echo"<td>". $row['FirstName']."</td>";
echo"<td>". $row['LastName']. "</td>";
echo"<td>". $row['PhoneNumber']. "</td>";
echo"<td> <button onclick=\"showHide('id'); return false;\">". $row['CompanyName']. "</button></td>";
echo"<td> <a href ='view.php?Id=$id'>Edit</a>";
echo"<td> <a href ='del.php?Id=$id'><center>Delete</center></a>";
echo "</tr>";
$CompanyName=$row['CompanyName'];
}
}
}
?>
</table>
<script type="text/javascript">
function showHide(id) {
$CompanyName=$row['CompanyName'];
if ($CompanyName = "Company A") {
<?php
echo "<table id='test1' style='width:50%' align='right'>";
include("db.php");
$result=mysql_query("SELECT * FROM company where no = '1'");
while($test = mysql_fetch_array($result))
{
$id = $test['No'];
echo "<th rowspan='1'>Company name</th>";
echo "<td colspan='3'>". $test['CompanyName']."</td>";
echo "</tr>";
echo "<tr>";
echo "<th>Location</th>";
echo "<td colspan='3'>". $test['Location']."</td>";
echo "</tr>";
echo "<tr>";
echo "<th>Found</th>";
echo "<td colspan='3'>". $test['Found']. "</td>";
echo "</tr>";
echo "<tr>";
echo "<th>Website</th>";
echo "<td colspan='3'>". $test['Website']. "</td>";
echo "</tr>";
echo "<tr>";
echo "<th rowspan='3'>Contact</th>";
echo "<th>Email</th>";
echo "<td colspan='3'>". $test['Email']. "</td>";
echo "</tr>";
echo "<tr>";
echo "<th>Phone</th>";
echo "<td colspan='3'>". $test['Phone']. "</td>";
echo "</tr>";
echo "<tr>";
echo "<th>Fax</th>";
echo "<td colspan='3'>". $test['Fax']. "</td>";
echo "</tr>";
echo "<br>";
}
mysql_close($conn);
?>
</table>
}
else if ($CompanyName = "Company B") {
<?php
echo "<table id='test2' style='width:50%' align='right'>";
include("db.php");
$result=mysql_query("SELECT * FROM company where no = '2'");
while($test = mysql_fetch_array($result))
{
$id = $test['No'];
echo "<th rowspan='1'>Company name</th>";
echo "<td colspan='3'>". $test['CompanyName']."</td>";
echo "</tr>";
echo "<tr>";
echo "<th>Location</th>";
echo "<td colspan='3'>". $test['Location']."</td>";
echo "</tr>";
echo "<tr>";
echo "<th>Found</th>";
echo "<td colspan='3'>". $test['Found']. "</td>";
echo "</tr>";
echo "<tr>";
echo "<th>Website</th>";
echo "<td colspan='3'>". $test['Website']. "</td>";
echo "</tr>";
echo "<tr>";
echo "<th rowspan='3'>Contact</th>";
echo "<th>Email</th>";
echo "<td colspan='3'>". $test['Email']. "</td>";
echo "</tr>";
echo "<tr>";
echo "<th>Phone</th>";
echo "<td colspan='3'>". $test['Phone']. "</td>";
echo "</tr>";
echo "<tr>";
echo "<th>Fax</th>";
echo "<td colspan='3'>". $test['Fax']. "</td>";
echo "</tr>";
echo "<br>";
}
mysql_close($conn);
?>
</table>
}
else if ($CompanyName= "Company C") {
<?php
echo "<table id='test3' style='width:50%' align='right'>";
include("db.php");
$result=mysql_query("SELECT * FROM company where no = '3'");
while($test = mysql_fetch_array($result))
{
$id = $test['No'];
echo "<th rowspan='1'>Company name</th>";
echo "<td colspan='3'>". $test['CompanyName']."</td>";
echo "</tr>";
echo "<tr>";
echo "<th>Location</th>";
echo "<td colspan='3'>". $test['Location']."</td>";
echo "</tr>";
echo "<tr>";
echo "<th>Found</th>";
echo "<td colspan='3'>". $test['Found']. "</td>";
echo "</tr>";
echo "<tr>";
echo "<th>Website</th>";
echo "<td colspan='3'>". $test['Website']. "</td>";
echo "</tr>";
echo "<tr>";
echo "<th rowspan='3'>Contact</th>";
echo "<th>Email</th>";
echo "<td colspan='3'>". $test['Email']. "</td>";
echo "</tr>";
echo "<tr>";
echo "<th>Phone</th>";
echo "<td colspan='3'>". $test['Phone']. "</td>";
echo "</tr>";
echo "<tr>";
echo "<th>Fax</th>";
echo "<td colspan='3'>". $test['Fax']. "</td>";
echo "</tr>";
echo "<br>";
}
mysql_close($conn);
?>
</table>
}
else if ($CompanyName = "Company D") {
<?php
echo "<table id='test4' style='width:50%' align='right'>";
include("db.php");
$result=mysql_query("SELECT * FROM company where no = '4'");
while($test = mysql_fetch_array($result))
{
$id = $test['No'];
echo "<th rowspan='1'>Company name</th>";
echo "<td colspan='3'>". $test['CompanyName']."</td>";
echo "</tr>";
echo "<tr>";
echo "<th>Location</th>";
echo "<td colspan='3'>". $test['Location']."</td>";
echo "</tr>";
echo "<tr>";
echo "<th>Found</th>";
echo "<td colspan='3'>". $test['Found']. "</td>";
echo "</tr>";
echo "<tr>";
echo "<th>Website</th>";
echo "<td colspan='3'>". $test['Website']. "</td>";
echo "</tr>";
echo "<tr>";
echo "<th rowspan='3'>Contact</th>";
echo "<th>Email</th>";
echo "<td colspan='3'>". $test['Email']. "</td>";
echo "</tr>";
echo "<tr>";
echo "<th>Phone</th>";
echo "<td colspan='3'>". $test['Phone']. "</td>";
echo "</tr>";
echo "<tr>";
echo "<th>Fax</th>";
echo "<td colspan='3'>". $test['Fax']. "</td>";
echo "</tr>";
echo "<br>";
}
mysql_close($conn);
?>
}
else {
alert("No such company exist...");
}
}
</script>
</body>
</html>
My table:
and what I want to display when I click on one of the button:
I just want to display another table when I click on one of the column and it has to be accurate (e.g. click Company C to get information of Company C).
Tried using function() ---> fail
Tried using if else ---> fail
You may want to use AJAX in order to achieve what you want.
Reminder: mysql_* is already deprecated, so you should consider mysqli_* instead.
First is, you need to list down your data in a table from info3 table, assuming that company table has CompanyName column in order to connect it to your info3 table's CompanyName column.
echo '<td> <button class="company_button">'.$row['CompanyName'].'</button></td>';
And create a div space for returned data of the clicked button.
<div id="company_desc_div"></div>
Then we can create a script using jQuery (javascript library) which you can download here.
$(document).on("click", ".company_button", function(){ /* WHEN A BUTTON IS CLICKED */
var company_desc = $(this).text(); /* GET WHAT COMPANY IS IT */
$.ajax({ /* START AJAX */
type: "POST", /* METHOD TO USE TO PASS THE DATA */
url: "get_company_info.php", /* FILE WHERE WE WILL PROCESS THE PASSED ON DATA */
data: { "company_desc": company_desc }, /* DATA TO BE PASSED ON */
success: function(result){ /* GET THE RETURNED DATA FROM get_company_info.php */
$("#company_desc_div").html(result); /* PUT THE RETURNED DATA TO company_desc_div DIV */
}
});
});
As you might notice, we pass the data of the clicked button to get_company_info.php, so lets create that file:
<?php
/* ESTABLISH YOUR CONNECTION */
$con = new mysqli("localhost", "root", "", "vauban");
/* CHECK CONNECTION */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
if($stmt = $con->prepare("SELECT CompanyName, Location, Found, Website, Email, Phone, Fax FROM company WHERE CompanyName = ?")){ /* PREPARE THE STATEMENT */
$stmt->bind_param("s", $_POST["company_desc"]); /* BIND THE PASSED ON DATA TO THE SELECT QUERY */
$stmt->execute(); /* EXECUTE THE QUERY */
$stmt->bind_result($companyname, $location, $found, $website, $email, $phone, $fax); /* BIND THE RESULT TO THESE VARIABLES */
$stmt->fetch(); /* FETCH THE RESULTS */
/* WHAT YOU ECHO IS WHAT WILL BE RETURNED TO THE AJAX REQUEST */
echo '<table>
<tr>
<th>Company name</th>
<td colspan="3">'.$companyname.'</td>
</tr>
<tr>
<th>Location</th>
<td colspan="3">'.$location.'</th>
</tr>
<tr>
<th>Found</th>
<td colspan="3">'.$found.'</td>
</tr>
<tr>
<th>Website</th>
<td colspan="3">'.$website.'</td>
</tr>
<tr>
<th rowspan="3">Contact</th>
<th>Email</th>
<td>'.$email.'</td>
</tr>
<tr>
<th>Phone</th>
<td colspan="3">'.$phone.'</td>
</tr>
<tr>
<th>Fax</th>
<td colspan="3">'.$fax.'</td>
</tr>
</table>';
$stmt->close();
} /* END OF PREPARED STATEMENT */
?>
What we echo from this file is what will be returned to the AJAX request.

Display table values in new window

EDIT:
Ok I found why it was not working. Jquery was ok but instead of value I took text, so instead .val just .text
So I have a little problem here.
I have a task to export outlook contact file and import it to a database, then display it in html table.
So I did that already and it was not that hard, but here is the next task:
I have my table, with a lot of rows and cells. My first cell is "First Name". When the user clicks on any of the "First Name" to open new window and create input textarea with the value of that cell.
So for example when I click on the name "Georgi" new window should popup with new textarea with the name "Georgi". When I click on "Tomas" new window should popup with new textarea with the name "Tomas". So this textarea should be universal for all names.
I mean I did it for only one name, but do not know how to do it for all names.
I hope you understood me what I want. Here is a picture of the table:
code:
<table id = "firstname" border="2" cellpadding="1" cellspacing="1" width="10000" >
<tr>
<th>First Name</th>
<th>Middle Name</th>
<th>Last Name</th>
<th>Suffix</th>
<th>Company</th>
<th>Department</th>
<th>Job Title</th>
<th>Business Street</th>
<th>Business Street 2</th>
<th>Business Street 3</th>
<th>Business City</th>
<th>Business State</th>
<th>Business Postal Code</th>
<th>Business Country/Region</th>
<th>Home Street</th>
<th>Home Street 2</th>
<th>Home Street 3</th>
<th>Home City</th>
<th>Home State</th>
<th>Home Postal Code</th>
<th>Home Country Region</th>
<th>Other Street</th>
<th>Other Street 2</th>
<th>Other Street 3</th>
<th>Other City</th>
<th>Other State</th>
<th>Other Postal Code</th>
<th>Other Country/Region</th>
<th>Assistant's Phone</th>
<th>Business Fax</th>
<th>Business Phone</th>
<th>Business Phone 2</th>
<th>Callback</th>
<th>Car Phone</th>
<th>Company Main Phone</th>
<th>Home Fax</th>
<th>Home Phone</th>
<th>Home Phone 2</th>
<th>ISDN</th>
<th>Mobile Phone</th>
<th>Other Fax</th>
<th>Other Phone</th>
<th>Pager</th>
<th>Primary Phone</th>
<th>Radio Phone</th>
<th>TTY/TDD PHone</th>
<th>Telex</th>
<th>Account</th>
<th>Anniversary</th>
<th>Assistant's Name</th>
<th>Billing Information</th>
<th>Birthday</th>
<th>Business Address PO Box</th>
<th>Categories</th>
<th>Children</th>
<th>Directory Server</th>
<th>Email Address</th>
<th>Email Type</th>
<th>Email Display Name</th>
<th>Email Address 2</th>
<th>Email Type 2</th>
<th>Email Display Name 2</th>
<th>Email Address 3</th>
<th>Email Type 3</th>
<th>Email Display Name 3</th>
<th>Gender</th>
<th>Government ID Number</th>
<th>Hobby</th>
<th>Home Address PO Box</th>
<th>Initials</th>
<th>Internet Free/Busy</th>
<th>Keywords</th>
<th>Language</th>
<th>Location</th>
<th>Manager's Name</th>
<th>Mileage</th>
<th>Notes</th>
<th>Office Location</th>
<th>Organizational ID Number</th>
<th>Other Address PO Box</th>
<th>Priority</th>
<th>Private</th>
<th>Profession</th>
<th>Referred By</th>
<th>Sensitivity</th>
</tr>
<tr class='table_row'>
<?php
mysqli_select_db($con,'outlook');
$sql = "SELECT * FROM contacts";
$myData = mysqli_query($con,$sql);
while($record = mysqli_fetch_array($myData))
{
echo "<tr>";
echo "<td id=\"fname\">" . "<a class='why' href='#' onClick='myFunction()'>" . $record['first_name'] . "</a>" . "</td>";
echo '<script type="text/javascript">';
echo 'function myFunction(){';
echo 'var myWindow = window.open("", "", "width=1024, height=555, left=450, top=100");';
echo 'myWindow.document.write(';
echo '"';
echo '<html>';
echo '<head>';
echo '<script src=\"http://code.jquery.com/jquery-1.9.1.js\"><\/script>';
echo '<script type=\"text/javascript\">';
echo '<\/script>';
echo '</head>';
echo '<body>';
echo '<div id=\"showcase\" style=\"background-color: #F5FFE0; margin-right: 25%; margin-left: 30%; padding-left:3%; padding-right:2%; border:solid 5px #242222;\">';
echo '<p style=\"background-color:#7A993D;\">Personal</p>';
echo '<select>';
echo '<option selected >Full Name</option>';
echo '</select>';
echo '<input type=\"text\" value=\"'.($record['first_name']).'\" style=\"margin-left: 25.3%;\"><br>';
echo '<select>';
echo '<option selected>Company</option>';
echo '</select>';
echo '<input type=\"text\" value=\"'.($record['company']).'\" style=\"margin-left: 26.3%;\"><br>';
echo '<select>';
echo '<option selected>Job Title</option>';
echo '</select>';
echo '<input type=\"text\" value=\"'.($record['job_title']).'\" style=\"margin-left: 28%;\"><br><br>';
echo '<p style=\"background-color:#7A993D;\">Internet</p>';
echo '<select>';
echo '<option>E-Mail</option>';
echo '<option>E-Mail 2</option>';
echo '<option>E-Mail 3</option>';
echo '</select>';
echo '<input type=\"text\" value=\"'.($record['email_address']).'\" style=\"margin-left: 28%;\"><br>';
echo '<select>';
echo '<option selected>Web page address</option>';
echo '</select>';
echo '<input type=\"text\" value=\"'.($record['internet_free_busy']).'\" style=\"margin-left: 12.5%;\"><br>';
echo '<p style=\"background-color:#7A993D;\">Phone numbers</p>';
echo '<select>';
echo '<option>Assistant</option>';
echo '<option selected>Business</option>';
echo '<option>Business 2</option>';
echo '<option>Business Fax</option>';
echo '<option>Callback</option>';
echo '<option>Car</option>';
echo '<option>Company</option>';
echo '<option>Home</option>';
echo '<option>Home 2</option>';
echo '<option>Home Fax</option>';
echo '<option>ISDN</option>';
echo '<option>Mobile</option>';
echo '<option>Other</option>';
echo '<option>Other Fax</option>';
echo '<option>Pager</option>';
echo '<option>Primary</option>';
echo '<option>Radio</option>';
echo '<option>Telex</option>';
echo '<option>TTY/TDD</option>';
echo '</select>';
echo '<script>';
echo 'var myColor = document.getElementById(\"fname\").value;';
echo '<\/script>';
echo '<input type=\"text\" value=myColor style=\"margin-left: 20%;\"><br>';
echo '<select>';
echo '<option>Assistant</option>';
echo '<option selected>Business</option>';
echo '<option>Business 2</option>';
echo '<option>Business Fax</option>';
echo '<option>Callback</option>';
echo '<option>Car</option>';
echo '<option>Company</option>';
echo '<option>Home</option>';
echo '<option>Home 2</option>';
echo '<option>Home Fax</option>';
echo '<option>ISDN</option>';
echo '<option>Mobile</option>';
echo '<option>Other</option>';
echo '<option>Other Fax</option>';
echo '<option>Pager</option>';
echo '<option>Primary</option>';
echo '<option>Radio</option>';
echo '<option>Telex</option>';
echo '<option>TTY/TDD</option>';
echo '</select>';
echo '<input type=\"text\" value=\"'.($record['business_phone']).'\" style=\"margin-left: 20%;\"><br>';
echo '<select>';
echo '<option>Assistant</option>';
echo '<option>Business</option>';
echo '<option>Business 2</option>';
echo '<option selected>Business Fax</option>';
echo '<option>Callback</option>';
echo '<option>Car</option>';
echo '<option>Company</option>';
echo '<option>Home</option>';
echo '<option>Home 2</option>';
echo '<option>Home Fax</option>';
echo '<option>ISDN</option>';
echo '<option>Mobile</option>';
echo '<option>Other</option>';
echo '<option>Other Fax</option>';
echo '<option>Pager</option>';
echo '<option>Primary</option>';
echo '<option>Radio</option>';
echo '<option>Telex</option>';
echo '<option>TTY/TDD</option>';
echo '</select>';
echo '<input type=\"text\" value=\"'.($record['business_fax']).'\" style=\"margin-left: 20%;\"><br>';
echo '<select>';
echo '<option>Assistant</option>';
echo '<option>Business</option>';
echo '<option>Business 2</option>';
echo '<option>Business Fax</option>';
echo '<option>Callback</option>';
echo '<option>Car</option>';
echo '<option>Company</option>';
echo '<option>Home</option>';
echo '<option>Home 2</option>';
echo '<option>Home Fax</option>';
echo '<option>ISDN</option>';
echo '<option selected>Mobile</option>';
echo '<option>Other</option>';
echo '<option>Other Fax</option>';
echo '<option>Pager</option>';
echo '<option>Primary</option>';
echo '<option>Radio</option>';
echo '<option>Telex</option>';
echo '<option>TTY/TDD</option>';
echo '</select>';
echo '<input type=\"text\" value=\"'.($record['mobile_phone']).'\" style=\"margin-left: 20%;\"><br>';
echo '<p style=\"background-color:#7A993D;\">Addresses</p>';
echo '<select>';
echo '<option selected>Business</option>';
echo '<option >Home</option>';
echo '<option >Other</option>';
echo '</select>';
echo '<input type=\"text\" value=\"'.($record['business_street']).'\" style=\"margin-left: 26.5%;\"><br><br>';
echo '<\/div>';
echo '</body></html>';
echo '"';
echo ');';
echo '}';
echo '</script>';
echo "<td>" . $record['middle_name'] . "</td>";
echo "<td>" . $record['last_name'] . "</td>";
echo "<td>" . $record['suffix'] . "</td>";
echo "<td>" . $record['company'] . "</td>";
echo "<td>" . $record['department'] . "</td>";
echo "<td>" . $record['job_title'] . "</td>";
echo "<td>" . $record['business_street'] . "</td>";
echo "<td>" . $record['business_street2'] . "</td>";
echo "<td>" . $record['business_street3'] . "</td>";
echo "<td>" . $record['business_city'] . "</td>";
echo "<td>" . $record['business_state'] . "</td>";
echo "<td>" . $record['business_postal_code'] . "</td>";
echo "<td>" . $record['business_country_region'] . "</td>";
echo "<td>" . $record['home_street'] . "</td>";
echo "<td>" . $record['home_street2'] . "</td>";
echo "<td>" . $record['home_street3'] . "</td>";
echo "<td>" . $record['home_city'] . "</td>";
echo "<td>" . $record['home_state'] . "</td>";
echo "<td>" . $record['home_postal_code'] . "</td>";
echo "<td>" . $record['home_country_region'] . "</td>";
echo "<td>" . $record['other_street'] . "</td>";
echo "<td>" . $record['other_street2'] . "</td>";
echo "<td>" . $record['other_street3'] . "</td>";
echo "<td>" . $record['other_city'] . "</td>";
echo "<td>" . $record['other_state'] . "</td>";
echo "<td>" . $record['other_postal_code'] . "</td>";
echo "<td>" . $record['other_country_region'] . "</td>";
echo "<td>" . $record['assistants_phone'] . "</td>";
echo "<td>" . $record['business_fax'] . "</td>";
echo "<td>" . $record['business_phone'] . "</td>";
echo "<td>" . $record['business_phone2'] . "</td>";
echo "<td>" . $record['callback'] . "</td>";
echo "<td>" . $record['car_phone'] . "</td>";
echo "<td>" . $record['company_main_phone'] . "</td>";
echo "<td>" . $record['home_fax'] . "</td>";
echo "<td>" . $record['home_phone'] . "</td>";
echo "<td>" . $record['home_phone2'] . "</td>";
echo "<td>" . $record['isdn'] . "</td>";
echo "<td>" . $record['mobile_phone'] . "</td>";
echo "<td>" . $record['other_fax'] . "</td>";
echo "<td>" . $record['other_phone'] . "</td>";
echo "<td>" . $record['pager'] . "</td>";
echo "<td>" . $record['primary_phone'] . "</td>";
echo "<td>" . $record['radio_phone'] . "</td>";
echo "<td>" . $record['tty_tdd_phone'] . "</td>";
echo "<td>" . $record['telex'] . "</td>";
echo "<td>" . $record['account'] . "</td>";
echo "<td>" . $record['anniversary'] . "</td>";
echo "<td>" . $record['assistants_name'] . "</td>";
echo "<td>" . $record['billing_information'] . "</td>";
echo "<td>" . $record['birthday'] . "</td>";
echo "<td>" . $record['business_address_po_box'] . "</td>";
echo "<td>" . $record['categories'] . "</td>";
echo "<td>" . $record['children'] . "</td>";
echo "<td>" . $record['directory_server'] . "</td>";
echo "<td>" . $record['email_address'] . "</td>";
echo "<td>" . $record['email_type'] . "</td>";
echo "<td>" . $record['email_display_name'] . "</td>";
echo "<td>" . $record['email_address2'] . "</td>";
echo "<td>" . $record['email_type2'] . "</td>";
echo "<td>" . $record['email_display_name2'] . "</td>";
echo "<td>" . $record['email_address3'] . "</td>";
echo "<td>" . $record['email_type3'] . "</td>";
echo "<td>" . $record['email_display_name3'] . "</td>";
echo "<td>" . $record['gender'] . "</td>";
echo "<td>" . $record['government_id_number'] . "</td>";
echo "<td>" . $record['hobby'] . "</td>";
echo "<td>" . $record['home_address_po_box'] . "</td>";
echo "<td>" . $record['initials'] . "</td>";
echo "<td>" . $record['internet_free_busy'] . "</td>";
echo "<td>" . $record['keywords'] . "</td>";
echo "<td>" . $record['language'] . "</td>";
echo "<td>" . $record['location'] . "</td>";
echo "<td>" . $record['managers_name'] . "</td>";
echo "<td>" . $record['mileage'] . "</td>";
echo "<td>" . $record['notes'] . "</td>";
echo "<td>" . $record['office_location'] . "</td>";
echo "<td>" . $record['organizational_id_number'] . "</td>";
echo "<td>" . $record['other_address_po_box'] . "</td>";
echo "<td>" . $record['priority'] . "</td>";
echo "<td>" . $record['private'] . "</td>";
echo "<td>" . $record['profession'] . "</td>";
echo "<td>" . $record['referred_by'] . "</td>";
echo "<td>" . $record['sensitivity'] . "</td>";
}
?>
</tr>
You could add an id to the desired td just like
echo "<td id='helper'>" . $record['middle_name'] . "</td>";
And then use jquery
$('#helper').click(function(){
var x=window.open();
x.document.open();
x.document.write('<textarea>'+$(this).val()+'</textarea>');
x.document.close();
});
Hope it worlks!
You can try this:( the window.open(...); function) link : w3schools the simple call just opens a window with the specified url, but there is also a custom call, that enables you to specify the content
ie:
var myWindow = window.open("", "MsgWindow", "width=200, height=100");
myWindow.document.write("<p>This is 'MsgWindow'. I am 200px wide and 100px tall!</p>");
example taken from the above page. I guess in your situation you just have to replace the <p>..</p> with some generated tags (which if I read correctly you already do)

Categories

Resources