【发布时间】:2011-12-20 14:53:54
【问题描述】:
我正在开发一个允许访问者使用此代码下载各种文档的网站:
<input type="button" class="downloadedFile" value="Download File" onclick="window.location.href=\'documents/' . $docsRow['docFileName'] . '\'" />
$docsRow['docFileName'] 是从 MySQL 数据库中检索到的每个文档的路径。
更大的图景是这些文档位于 jQuery 手风琴中,每个手风琴窗格都是一个包含一个或多个文档的类 - 像这样:
<div id="accordion">
<h3><a href="#">LEAD5220 - Leader as Change Agent</a></h3>
<div>
<p class="className">Leader as Change Agent</p>
<p class="classNumber">LEAD5220</p>
<hr class="classSeparator" />
<table width="95%">
<tr>
<td><strong>Document Name:</strong> Generic Annotation Format</td>
<td width="100px" align="right"><input type="button" class="downloadedFile" value="Download File" onclick="window.location.href='documents/Generic Annotation Format.docx'" /></td>
</tr>
<tr>
<td colspan="2"><strong>Description:</strong> This document can be used as a template for your annotations in the annotated bibliography forums.</td>
</tr>
</table>
<hr class="classSeparator" />
...
我的客户希望能够计算每个文档每个班级的下载次数。
我知道我可以通过 javascript 检测按钮点击,就“每个类”部分而言,我可以使用 jQuery 来检测按钮点击的类表,但我不明白的是 1)如何将该信息获取到 PHP/MySQL 代码中以记录到数据库中,以及 2)我是否只能检测到按钮单击,或者我是否可以检测到用户是否实际将文件下载到他们的计算机(这些是 PDF、DOC、XLS文件)。
感谢大家的帮助!
【问题讨论】:
标签: php javascript jquery download counter