我有一个 asp.net 列表视图,其中包含一个列,2 个输入类型 = 按钮(id=Start,id=Stop,1 个输入类型 = 文本(id=TimeMINutes)和 1 个跨度(id=spCountDown)。从包括列表视图在内的所有这些控件都是...
<table id="ctl00_ContentPlaceHolder1_lstViewFormulas_itemPlaceholderContainer" style="vertical-align:top; border:solid 1px gray">
<tr id="ctl00_ContentPlaceHolder1_lstViewFormulas_Tr1" style="vertical-align:top; border:solid 1px gray">
<td class="ListViewHeader" style="width:20%">
<span id="ctl00_ContentPlaceHolder1_lstViewFormulas_lblFormName">Step Name</span></td>
<td class="ListViewHeader" style="width:10%" align="center">
<span id="ctl00_ContentPlaceHolder1_lstViewFormulas_lblTiming">Timing</span></td>
<td class="ListViewHeader" style="width:30%">
<span id="ctl00_ContentPlaceHolder1_lstViewFormulas_Label6">Area Used</span></td>
<td class="ListViewHeader" style="width:10%">
<span id="ctl00_ContentPlaceHolder1_lstViewFormulas_lblClock">Timer</span></td>
<td class="ListViewHeader" style="width:30%">
<span id="ctl00_ContentPlaceHolder1_lstViewFormulas_lblProd">Products</span></td>
</tr>
<tr style="">
<td>
<span id="ctl00_ContentPlaceHolder1_lstViewFormulas_ctrl0_lblFormName">Step 1</span>
</td>
<td>
<span id="ctl00_ContentPlaceHolder1_lstViewFormulas_ctrl0_lblTiming">20</span>
</td>
<td>
<span id="ctl00_ContentPlaceHolder1_lstViewFormulas_ctrl0_lblAreaUsed">Scalp</span>
</td>
<td>
<input type="button" onclick="countdown(document.getElementById('TimeMinutes'), document.getElementById('spCountDown'))"; value="Start" id="Start" />
<input type="button" onclick='stopcountdown()'; value="Stop" id="Stop" />
<input type="text" value='20' id="TimeMinutes" />
<span id="spCountDown"></span>
</td>
我正在尝试将“TimeMinutes”输入类型 =“text”和“spCountDown”Span 传递给 javascript 函数。
我尝试了几种方法,包括...
<input type="button" onclick="countdown(document.getElementById('TimeMinutes'), document.getElementById('spCountDown'))"; value="Start" id="Start" />
我还尝试使用输入 id 在 javascript 函数中找到这些控件,但我没有找到正确的行。
我需要从输入 type = text 中获取值,并在 javascript 函数中开始倒计时。
var interval;
var seconds=0;
function countdown(txtminutes, spanid) {
interval = setInterval(function () {
var sp = document.getElementById("spanid");
var minutes = document.getElementById("txtminutes").value
if (seconds == 0) {
if (minutes == 0) {
sp.innerHTML = "countdown's over!";
clearInterval(interval);
return;
} else {
minutes--;
seconds = 60;
}
}
if (minutes > 0) {
var minute_text = minutes + (minutes > 1 ? ' minutes' : ' minute');
} else {
var minute_text = '';
}
var second_text = seconds > 1 ? 'seconds' : 'second';
sp.innerHTML = minute_text + ' ' + seconds + ' ' + second_text + ' remaining';
seconds--;
}, 1000);
}
function stopcountdown() {
window.clearInterval(interval);
var sp = document.getElementById("CountDown");
sp.innerHTML = ''
}
如何传入这些控件,以便从正确的行获取和设置正确的值?
谢谢