|
Client list - Open button - How do i execute?
11-23-2005, 01:31 AM
|
Client list - Open button - How do i execute?
|
Posts: 626
|
I have a client list with some of the following variables:
$ClientNumber
$LastName
$FirstName
etc...
Code:
<input type="image" src="file_open.jpg" onclick="<?php OpenFile($ClientNumber);?>" width="20px">
This is not working.
Can anyone help me execute this? I have a pic which when clicked should open current file.
Zinc.
|
|
|
|
11-23-2005, 04:31 AM
|
|
Posts: 1,832
Location: Somewhere else entirely
|
The onclick handler is for running client side script, such as Javascript. Once the page has left the server, PHP has done its job and you can't run any more. Is the image on your server or is it an image that the client has on their machine? If the image is on your server you could put an img tag into the page and make it hidden, and then use javascript to show it when the button is clicked. Not sure of the exact code for this, since I'm not a Javascript expert.
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';
Please login or register to view this content. Registration is FREE (aka MSN handwriting for forums)
|
|
|
|
11-23-2005, 01:12 PM
|
|
Posts: 626
|
Sorry I guess I wasn't clear... The image is on my machine. It is a database that I am creating for my intranet.
The list shows up like this:
$LastName $FirstName $Address $PhoneNumber <img> <img> <img>
Where "<img>" is actually the previous <input> tag with type set to image.
This appears on every line as the page is loaded (which is how I wanted it). Now, lets say the user wants to edit a particular client, then they would click on the edit image and at that point I want to execute a function so that I can populate a form with the $ClientNumber and then sumbit the form to the edit page where it will extract the $ClientNumber from the $_POST variables. My problem is that when I try to click the image, I am getting an error message.
Hopefully, this clears it up.
|
|
|
|
11-23-2005, 01:38 PM
|
|
Posts: 626
|
Now I am getting an alert box telling me "Runtime error: Line 43 - Object expected"
Here is my code:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript" language="javascript">
function OpenClient(ClientNum) {
alert(ClientNum);
}
</script>
</head>
<body bgcolor="#CCCCCC" style="font-family:Arial, Helvetica, sans-serif; font-size:12px; ">
<?php
$clients_contents = "";
$conn = mysql_connect('localhost', 'root', 'password') or die('Sorry connection faild!');
mysql_select_db("Clientbase");
$query = "SELECT *
FROM Clientbase
ORDER BY LastName, FirstName, HomeAddress1";
$results = mysql_query($query,$conn) or die(mysql_error());
$clients_header =<<<HEADER
<table cellpadding="0" cellspacing="0" align="center" width="100%" style="background-color:#FFFFFF; border:1px solid black;">
<tr valign="middle">
<th height="50px" align="center" colspan="11" style="background-color:#6699FF; font-size:25px; font-weight:bold;">
Client List
</th>
<tr>
<tr>
<th width="14%" height="22px" align="left" style="border-bottom:1px solid #000000;"><b>Last Name</b></th>
<th width="13%" height="22px" align="left" style="border-bottom:1px solid #000000;"><b>First Name</b></th>
<th width="10%" height="22px" align="left" style="border-bottom:1px solid #000000;"><b>Home Phone</b></th>
<th width="10%" height="22px" align="left" style="border-bottom:1px solid #000000;"><b>Work Phone</b></th>
<th width="8%" height="22px" align="left" style="border-bottom:1px solid #000000;"><b>Birthdate</b></th>
<th width="20%" height="22px" align="left" style="border-bottom:1px solid #000000;"><b>Address</b></th>
<th width="10%" height="22px" align="left" style="border-bottom:1px solid #000000;"><b>City</b></th>
<th width="6%" height="22px" align="left" style="border-bottom:1px solid #000000;"><b>Postal</b></th>
<th width="3%" height="22px" style="border-bottom:1px solid #000000;"> </th>
<th width="3%" height="22px" style="border-bottom:1px solid #000000;"> </th>
<th width="3%" height="22px" style="border-bottom:1px solid #000000;"> </th>
</tr>
<tr>
<th colspan="11" height="5px" style="font-size:5px;"> </th>
HEADER;
while($rows = mysql_fetch_array($results)){
extract($rows);
// $DOB = date("m/d/Y",$DOB);
// Format the phone numbers to include dashes
if(!empty($HomePhone)){
$HmPhone = substr($HomePhone, 0, 3).'-'.substr($HomePhone,3,3).'-'.substr($HomePhone,6,4);
} else {
$HmPhone = $HomePhone;
}
// Format the phone numbers to include dashes
if(!empty($WorkPhone)){
$WkPhone = substr($WorkPhone, 0, 3).'-'.substr($WorkPhone,3,3).'-'.substr($WorkPhone,6,4);
} else {
$WkPhone = $WorkPhone;
}
// Format the postal codes to include a space
if(!empty($HomePostal)){
$HmPostal = substr($HomePostal, 0, 3).' '.substr($HomePostal,3,3);
} else {
$HmPostal = $HomePostal;
}
$clients_contents .=<<<CONTENTS
<tr>
<td>$LastName</td>
<td>$FirstName</td>
<td>$HmPhone</td>
<td>$WkPhone</td>
<td>$DOB</td>
<td>$HomeAddress1</td>
<td>$HomeCity</td>
<td>$HmPostal</td>
<td width="3%" height="22px" align="center">
<input type="image" src="file_open.jpg" title="Open" onclick="javascript:ClientOpen($ClientNumber);" width="20px">
</td>
<td width="3%" height="22px" align="center">
<input type="image" src="file_edit.gif" title="Edit" onclick="" width="20px">
</td>
<td width="3%" height="22px" align="left">
<input type="image" src="file_delete.gif" title="Delete" onclick="" width="20px">
</td>
</tr>
CONTENTS;
}
$clients_footer = '</table>';
echo $clients_header;
echo $clients_contents;
echo $clients_footer;
?>
</body>
</html>
What is wrong???
|
|
|
|
11-23-2005, 02:47 PM
|
|
Posts: 1,832
Location: Somewhere else entirely
|
<input> tags are for use in HTML forms that submit data back to the server. If you want an image to pop up or be displayed in the page, I would use PHP to echo an invisible image tag, and have the js unhide it.
There may be other ways to do it that are better, as I said I'm not a js expert. I've moved this to the Javascript forums so someone more familiar with js can help you out.
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';
Please login or register to view this content. Registration is FREE (aka MSN handwriting for forums)
|
|
|
|
11-23-2005, 03:21 PM
|
|
Posts: 635
|
If you just want to insert the Clientnumber into a formfield, it's pretty easy, but where is the field you want to insert it into? Also, it should be:
Code:
onclick="ClientOpen($ClientNumber);"
no "Javascript :" is needed in the onclick handler.
Last edited by funkdaddu; 11-23-2005 at 03:35 PM..
|
|
|
|
11-23-2005, 03:43 PM
|
|
Posts: 635
|
Is this what you were looking for kinda?
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript" language="javascript">
function OpenClient(ClientNum) {
document.MyForm.ClientNumber.value = ClientNum;
}
</script>
</head>
<body bgcolor="#CCCCCC" style="font-family:Arial, Helvetica, sans-serif; font-size:12px; ">
<?php
$clients_contents = "";
$conn = mysql_connect('localhost', 'root', 'password') or die('Sorry connection faild!');
mysql_select_db("Clientbase");
$query = "SELECT *
FROM Clientbase
ORDER BY LastName, FirstName, HomeAddress1";
$results = mysql_query($query,$conn) or die(mysql_error());
$clients_header =<<<HEADER
<table cellpadding="0" cellspacing="0" align="center" width="100%" style="background-color:#FFFFFF; border:1px solid black;">
<tr valign="middle">
<th height="50px" align="center" colspan="11" style="background-color:#6699FF; font-size:25px; font-weight:bold;">
Client List
</th>
<tr>
<tr>
<th width="14%" height="22px" align="left" style="border-bottom:1px solid #000000;"><b>Last Name</b></th>
<th width="13%" height="22px" align="left" style="border-bottom:1px solid #000000;"><b>First Name</b></th>
<th width="10%" height="22px" align="left" style="border-bottom:1px solid #000000;"><b>Home Phone</b></th>
<th width="10%" height="22px" align="left" style="border-bottom:1px solid #000000;"><b>Work Phone</b></th>
<th width="8%" height="22px" align="left" style="border-bottom:1px solid #000000;"><b>Birthdate</b></th>
<th width="20%" height="22px" align="left" style="border-bottom:1px solid #000000;"><b>Address</b></th>
<th width="10%" height="22px" align="left" style="border-bottom:1px solid #000000;"><b>City</b></th>
<th width="6%" height="22px" align="left" style="border-bottom:1px solid #000000;"><b>Postal</b></th>
<th width="3%" height="22px" style="border-bottom:1px solid #000000;"> </th>
<th width="3%" height="22px" style="border-bottom:1px solid #000000;"> </th>
<th width="3%" height="22px" style="border-bottom:1px solid #000000;"> </th>
</tr>
<tr>
<th colspan="11" height="5px" style="font-size:5px;"> </th>
HEADER;
while($rows = mysql_fetch_array($results)){
extract($rows);
// $DOB = date("m/d/Y",$DOB);
// Format the phone numbers to include dashes
if(!empty($HomePhone)){
$HmPhone = substr($HomePhone, 0, 3).'-'.substr($HomePhone,3,3).'-'.substr($HomePhone,6,4);
} else {
$HmPhone = $HomePhone;
}
// Format the phone numbers to include dashes
if(!empty($WorkPhone)){
$WkPhone = substr($WorkPhone, 0, 3).'-'.substr($WorkPhone,3,3).'-'.substr($WorkPhone,6,4);
} else {
$WkPhone = $WorkPhone;
}
// Format the postal codes to include a space
if(!empty($HomePostal)){
$HmPostal = substr($HomePostal, 0, 3).' '.substr($HomePostal,3,3);
} else {
$HmPostal = $HomePostal;
}
$clients_contents .=<<<CONTENTS
<tr>
<td>$LastName</td>
<td>$FirstName</td>
<td>$HmPhone</td>
<td>$WkPhone</td>
<td>$DOB</td>
<td>$HomeAddress1</td>
<td>$HomeCity</td>
<td>$HmPostal</td>
<td width="3%" height="22px" align="center">
<input type="image" src="file_open.jpg" title="Open" onclick="OpenClient($ClientNumber);" width="20px">
</td>
<td width="3%" height="22px" align="center">
<input type="image" src="file_edit.gif" title="Edit" onclick="" width="20px">
</td>
<td width="3%" height="22px" align="left">
<input type="image" src="file_delete.gif" title="Delete" onclick="" width="20px">
</td>
</tr>
CONTENTS;
}
$clients_footer = '</table>';
echo $clients_header;
echo $clients_contents;
echo $clients_footer;
?>
<form id="MyForm" action="#" method="get" name="MyForm">
<input type="text" name="ClientNumber" size="24"><input type="submit" name="submitButtonName">
</form>
</body>
</html>
It will only work with numbers, if you need to use letters in the client number add ' ' around the $ClientNumber.
|
|
|
|
11-24-2005, 01:59 AM
|
|
Posts: 626
|
Thank you... I don't know what I was doing wrong but I was able to adapt your code for the functionality that I was looking for.
Thanks again.
|
|
|
|
|
« Reply to Client list - Open button - How do i execute?
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|