How to change hyperlink behavior from double-click to single-click
here is my code, i would like my links to open with just a single click. all i开发者_运维百科s functioning properly, its just that, the delete,approve ant not approve link must be double click for its function to run. i hope someone could hear me.
index.php
<?php
$search = '%';
$fgmembersite->DBLogin();
$limit = 5;
if(isset($_GET['offset'])) {
$offset = mysql_real_escape_string($_GET['offset']);
} else {
$offset = 0;
}
//for namelist a-z
$listname = '%';
If (isset($_GET['namelist']))
{
$listname = $_GET['namelist'];
}
//for search file
if(isset($_POST['searchfile']))
{
$search = $_POST['searchfile'];
}
else if(isset($_GET['searchfile']))
{
$search = $_GET['searchfile'];
}
if($_SESSION[$fgmembersite->GetLoginSessionVar()] == 'sa' OR $_SESSION[$fgmembersite->GetLoginSessionVar()] == 'admin')
{
$sql="select * from gmdc_employee where employee_name like '%$search%' AND employee_name like '$listname%' ";
}
else
{
$sql = "select b.* from gmdc_user a, gmdc_employee b where a.username = '".$_SESSION[$fgmembersite->GetLoginSessionVar()]."' and a.company_id = b.company_id AND b.employee_name like '$listname%' AND b.employee_name like '%$search%'";
}
$query = mysql_query("$sql ORDER BY employee_name,confirmation DESC ,file_id DESC,file_date DESC LIMIT $offset,$limit") or die ( mysql_error () );
$result = mysql_query($sql) or die (mysql_error());
$total = mysql_num_rows($result);
if(!$result || mysql_num_rows($result) <= 0)
{
$fgmembersite->HandleError("No file found.");
return false;
}
while ($row = mysql_fetch_assoc($query))
{
$file_id = $row['file_id'];
$file_desc = $row['file_description'];
$file_date = $row['file_date'];
$file_name = $row['file_name'];
$file_accs = $row['folder_access'];
$file_employee = $row['employee_id'];
$file_confir = $row['confirmation'];
$file_ename = ucwords($row['employee_name']);
$info = pathinfo($file_name);
$file_ext = $info['extension'];
echo '<tr>
<td>
</td>
</tr>
<tr class="subone">
<td class="sub" width="100">
'.$file_employee.'
<br />
</td>';
if($_SESSION[$fgmembersite->GetLoginSessionVar()] == 'sa')
{
?><td class="sub" width="100">
<a href="" onclick = javascript:newPopup('addfile.php?emp=<?php echo $file_employee ?>');><?php echo$file_ename?></a>
<br />
</td><?php
}
else
{
echo '<td class="sub" width="182">
'.$file_ename.'
<br />
</td>';
}
echo'<td class="sub" width="218">
<a href="'.$file_accs.$file_name.'" target="_blank" style="text-decoration: underline;">'.$file_desc.'</a>
<br />
</td>
<td class="sub" width="100">
'.date('M d, Y',mktime(0,0,0,substr($file_date,5,2),substr($file_date,8,2),substr($file_date,0,4))).'
<br />
</td>
<td class="sub" width="100">
'.$file_confir.'
<br />
</td>';
if($_SESSION[$fgmembersite->GetLoginSessionVar()] == 'sa')
{
if($file_confir == 'Pending' OR $file_confir == 'NotApproved')
{
if(isset($_GET['id']))
{
$fgmembersite->Delete_Db($_GET['id']);
}
echo '<td class="sub" width="100">
<a href="index.php?id='.$file_id.'">Delete</a>
<br />
</td>';
}
}
else if($_SESSION[$fgmembersite->GetLoginSessionVar()] == 'admin')
{
if($file_confir == 'Pending')
{
if(isset($_GET['yes']))
{
$fgmembersite->UpdateYesDB($_GET['yes']);
}
else if(isset($_GET['no']))
{
$fgmembersite->UpdateNoDB($_GET['no']);
}
echo'<td class="sub" width="100">
<a href="index.php?yes='.$file_id.'">Approve</a>
<br /><br />
<a href="index.php?no='.$file_id.'">NotApprove</a>
</td> ';
}
}
}?>
*fg_membersite.php*
function Delete_Db($id)
{
$ok = mysql_query("DELETE FROM gmdc_employee WHERE file_id='$id'");
if (!$ok)
{
$this->HandleError("Error deleting profile from database!");
}
}
function UpdateYesDB($fid)
{
$this->DBLogin();
$yes = mysql_query("UPDATE gmdc_employee SET confirmation='Approved' WHERE file_id = '$fid'");
if (!$yes)
{
$this->HandleError("Error updating from database!");
return false;
}
}
function UpdateNoDB($fids)
{
$this->DBLogin();
$no = mysql_query("UPDATE gmdc_employee SET confirmation='NotApproved' WHERE file_id = '$fids'");
if (!$no)
{
$this->HandleError("Error updating from database!");
return false;
}
}
*note, i only put the delete/approve/not approve function because thats my only problem. thanks
HTML links do typically not require double clicks, you probably have some other element that is overlapping your link or some script that is interfering.
Please show the complete source for the affected page.
Try looking at your completed markup in a tool like firebug.
Please modify the quote usage in the section as follows.
echo "<td class='sub' width='100'><a href='index.php?yes=".$file_id."'>Approve</a><br /><br /><a href='index.php?no=".$file_id."'>NotApprove</a></td>";
Please let me know if you need any clarification.
It will be better if you could provide me the code of that link. I am wondering whether you are using Javascript function or just link to go to a new page from update and delete Anchor tag.
精彩评论