/    Sign up×
Community /Pin to ProfileBookmark

Javascript Table ‘Row Hover’ & Confirmation

Hi… I hope someone can help me here.

I’m using javascript to change the colour of a table row when a user hover there mouse over it, also, when they click anywhere on the row it takes the user to a DETAILS page.

But each row also contains a link to delete the record.. It asks a javascript confirmation if they wish to delete – If they do, it goes to the DELETE record page, if they choose no it’s suppose to do nothing… But instead, it shows the DETAILS page because the user has clicked on the row.

Does anyone know a way around this?

I’ve included some sample code, and an attachment.

Thanks for any help on this.

[CODE]
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″ />
<title>Zapatos Designer Shoes Admin Administration: Shoes</title>
<style>
table.tableDesign1 { border-collapse: collapse; border-spacing: 0px; background-color: #CCCCCC; }
table.tableDesign1 thead { font-weight: bold; }
table.tableDesign1 th, table.tableDesign1 thead th { font-weight: bold; text-align: left; }
table.tableDesign1 td { border-bottom: 1px #90BBEF solid; padding: 4px; }

.highlightRow { background-color: #FFFFFF; cursor: pointer; }
.normalRow { background-color: #CCCCCC; }
</style>
<script language=”javascript” type=”text/javascript”>
<!–

var limitWindowAccess = false;

function confirmDelete(shoeID) {
if (confirm(“Are you sure you wish to delete this shoe from the database?”))
{
window.location = “delshoe.asp?shoeID=” + shoeID;
} else {
confirmDelete = false;
limitWindowAccess = true;
//return false;
}
}
–>
</script>
</head>

<body>
<br />
<br />

<table width=”98%” border=”1″ align=”center” cellpadding=”0″ cellspacing=”0″ class=”tableDesign1″>
<thead>
<tr>
<td width=”14%”>ID</td>
<td width=”69%”>Designer</td>
<td width=”69%” align=”right”>RRP</td>
<td width=”10″>&nbsp;</td>
<td width=”17%” nowrap=”nowrap”>Options</td>
</tr>
</thead>
<tbody>

<tr onMouseOver=”this.className=’highlightRow'” onMouseOut=”this.className=’normalRow'” onclick=”if(limitWindowAccess==false){window.location=’editshoe.asp?shoeID=64′}else{limitWindowAccess=false}”>
<td>64</td>
<td>Shoe #63</td>
<td align=”right”>£348.00</td>
<td width=”10″>&nbsp;</td>
<td nowrap=”nowrap”><a href=”editshoe.asp?shoeID=64″>Edit</a>&nbsp;|&nbsp;<a href=”javascript: confirmDelete(’64’);”>Delete</a></td>
</tr>

<tr onMouseOver=”this.className=’highlightRow'” onMouseOut=”this.className=’normalRow'” onclick=”if(limitWindowAccess==false){window.location=’editshoe.asp?shoeID=82′}else{limitWindowAccess=false}”>
<td>82</td>
<td>Shoe #81</td>
<td align=”right”>£84.00</td>
<td width=”10″>&nbsp;</td>
<td nowrap=”nowrap”><a href=”editshoe.asp?shoeID=82″>Edit</a>&nbsp;|&nbsp;<a href=”javascript: confirmDelete(’82’);”>Delete</a></td>
</tr>

<tr onMouseOver=”this.className=’highlightRow'” onMouseOut=”this.className=’normalRow'” onclick=”if(limitWindowAccess==false){window.location=’editshoe.asp?shoeID=101′}else{limitWindowAccess=false}”>
<td>101</td>
<td>Shoe #100</td>
<td align=”right”>£96.00</td>
<td width=”10″>&nbsp;</td>
<td nowrap=”nowrap”><a href=”editshoe.asp?shoeID=101″>Edit</a>&nbsp;|&nbsp;<a href=”javascript: confirmDelete(‘101’);”>Delete</a></td>
</tr>

</tbody>
</table>

</body>
</html>
[/CODE]

[upl-file uuid=e6b2fdf1-dc7e-4060-bc1b-55b0b5cce185 size=3kB]example.txt[/upl-file]

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @Drummer_si spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...