【发布时间】:2014-05-31 00:04:33
【问题描述】:
我在 js 中有一个 crono 应用程序,但我需要将该 var 传递给 php 中的模式,我有这个(它是一个嵌入表)
<table>
<thead>
<th>Project</th>
<th>Task</th>
<th>Tieme</th>
<th><th>
</thead>
<tbody>
<tr>
<td>".$res[0]."</td>
<td>".$res[1]."</td>
<td > <form name='crono' class='large-6'>
<input type='text' name='face' title='Cronomet'>
<script type='text/javascript'>
var timeCrono;
var hor = 0;
var min = 0;
var seg = 0;
var startTime = new Date();
var start = startTime.getSeconds();
var startchron = 0;
StartCrono();
function StartCrono() {
if (startchron == 1) {
if (seg + 1 > 59) {
min += 1;
}
if (min > 59) {
min = 0;
hor += 1;
}
var time = new Date();
if (time.getSeconds() >= start) {
seg = time.getSeconds() - start;
}
else {
seg = 60 + (time.getSeconds() - start);
}
timeCrono = (hor < 10) ? '0' + hor : hor;
timeCrono += ((min < 10) ? ':0' : ':') + min;
timeCrono += ((seg < 10) ? ':0' : ':') + seg;
document.crono.face.value = timeCrono;
setTimeout('StartCrono()', 1000);
console.log(timeCrono);
}
}
function stopChr() {
startchron = 0;
$('#data').text(timeCrono);
}
function startChr() {
startchron = 1;
StartCrono();
}
</script>
</form>
</td>
<td><input type='button' id='btnstart'onclick='startChr();' class='button' value='START'></td>
<td> <a href='#' data-reveal-id='ventana' id='addhrs'><input type='button' id='btnstop'onclick='stopChr();' class='button' value='STOP'></a></td>
</tr>
</tbody>
</table>";
我需要格式为 00:00:00 的 'timeCrono' 值,当按下停止按钮(函数 stopChr)时,会出现一个模式,其中包含我所拥有的信息就是该值的文本 $('#data ').text(timeCrono);
但我需要将该文本传递给 a 或类似的值,#data 也是标签
<p id='data'></p>,我想要的结果类似于<p id='data' value='00:00:00'>.
【问题讨论】:
-
查看 developer.mozilla.org/en/docs/AJAX 了解有关 AJAX 的更多信息。
标签: javascript php