下面的代碼是顯示每個選項作爲複選框按鈕對每個問題的一個動態的方式:如何停止響應時間和計數鼠標點擊
function ExpandOptionType($option) {
$options = explode('-', $option);
if(count($options) > 1) {
$start = array_shift($options);
$end = array_shift($options);
do {
$options[] = $start;
}while(++$start <= $end);
}
else{
$options = explode(' or ', $option);
}
echo '<p>';
foreach($options as $indivOption) {
echo '<div id="ck-button"><label class="fixedLabelCheckbox"><input type="checkbox" name="options[]" id="option-' . $indivOption . '" value="' . $indivOption . '" /><span>' . $indivOption . '</span></label></div>';
}
echo '</p>';
}
foreach ($arrQuestionId as $key=>$question) {
?>
<p><?php echo ExpandOptionType(htmlspecialchars($arrOptionType[$key])); ?></p>
<p><input type='text' class='questionIds' name='questionids' value='<?php echo htmlspecialchars($arrQuestionId[$key]); ?>' /></p>
<p><input type='text' class='responseTime' name='responsetime' value='00:00:00' /></p>
<p><input type='text' class='mouseClick' name='mouseclick' value='0' /></p>
}
現在下面I 2個文本輸入也被加foreach循環,一個用於響應時間等是用於計算鼠標點擊:
<p><input type='text' class='responseTime' name='responsetime' value='00:00:00' /></p>
<p><input type='text' class='mouseClick' name='mouseclick' value='0' /></p>
現在,這是我的問題:
響應時間文本輸入包含一個遞增計時器。我想要的是,如果在問題中單擊第一個按鈕複選框,則問題的響應計時器應停止。這是因爲我們知道用戶回答一個特定問題需要多長時間
鼠標單擊文本以0開頭,我希望這個文本輸入要做的是爲每個按鈕複選框單擊一個問題,問題的鼠標點擊文本輸入會計算點擊量,因此我們知道用戶編譯的問題選項上有多少點擊。
如何才能達到上述目的?
下面是什麼樣子的一個問題上的jsfiddle顯示示例代碼:
http://jsfiddle.net/zAFND/630/
UPDATE:
的源代碼顯示多個問題,例如:
QUESTION 1:
<p>
<div id="ck-button">
<label class="fixedLabelCheckbox">
<input type="checkbox" name="options[]" id="option-A" value="A" />
<span>A</span>
</label>
</div>
<div id="ck-button">
<label class="fixedLabelCheckbox">
<input type="checkbox" name="options[]" id="option-B" value="B" />
<span>B</span>
</label>
</div>
<div id="ck-button">
<label class="fixedLabelCheckbox">
<input type="checkbox" name="options[]" id="option-C" value="C" />
<span>C</span>
</label>
</div>
<div id="ck-button">
<label class="fixedLabelCheckbox">
<input type="checkbox" name="options[]" id="option-D" value="D" />
<span>D</span>
</label>
</div>
<div id="ck-button">
<label class="fixedLabelCheckbox">
<input type="checkbox" name="options[]" id="option-E" value="E" />
<span>E</span>
</label>
</div>
<div id="ck-button">
<label class="fixedLabelCheckbox">
<input type="checkbox" name="options[]" id="option-F" value="F" />
<span>F</span>
</label>
</div>
</p>
<p><input type='text' class='questionIds' name='questionids' value='73' /></p>
<p><input type='text' class='responseTime' name='responsetime' value='00:00:00' /></p>
<p><input type='text' class='mouseClick' name='mouseclick' value='0' /></p>
QUESTION 2:
<p>
<div id="ck-button">
<label class="fixedLabelCheckbox">
<input type="checkbox" name="options[]" id="option-A" value="A" />
<span>A</span>
</label>
</div>
<div id="ck-button">
<label class="fixedLabelCheckbox">
<input type="checkbox" name="options[]" id="option-B" value="B" />
<span>B</span>
</label>
</div>
<div id="ck-button">
<label class="fixedLabelCheckbox">
<input type="checkbox" name="options[]" id="option-C" value="C" />
<span>C</span>
</label>
</div>
<div id="ck-button">
<label class="fixedLabelCheckbox">
<input type="checkbox" name="options[]" id="option-D" value="D" />
<span>D</span>
</label>
</div>
<div id="ck-button">
<label class="fixedLabelCheckbox">
<input type="checkbox" name="options[]" id="option-E" value="E" />
<span>E</span>
</label>
</div>
</p>
<p><input type='text' class='questionIds' name='questionids' value='74' /></p>
<p><input type='text' class='responseTime' name='responsetime' value='00:00:00' /></p>
<p><input type='text' class='mouseClick' name='mouseclick' value='0' /></p>
該計時器是否也適用於用戶?如果不緩存$。現在()複選框單擊,然後在下一個$ .now() - 緩存的一個&將該值放到已回答問題旁邊的隱藏輸入;代碼會更簡單 – mikakun 2013-02-09 04:07:53
@mikakun文本輸入將被改變爲隱藏輸入,我只是將它作爲文本輸入放置,以便我可以看到值以知道發生了什麼。 – user2056342 2013-02-09 04:08:55
所以使用$ .now()複選框單擊&表單提交(爲最後一個);讓你的點擊全球陣列與一個索引爲每個問題,你增加點擊 – mikakun 2013-02-09 04:13:52