<c:if test="${not empty timeout}">
<c:choose>
<c:when test="${startclicked=='lunch'}">
<div class="f-left lf_rt5">
<c:if test="${startclicked !='break'}">
<button type="submit" id="start-break" name="start" value="start-break" disabled="disabled"
type="button" class="actv-btn-dft1 blbg" onclick="return startbreak();" title="Start Break">
Start Break
</button>
</c:if>
<c:if test="${empty stopclicked && startclicked =='break'}">
<button type="submit" id="stop-break" name="stop" value="stop-break" disabled="disabled"
type="button" class="actv-btn-dft1 orbg" onclick="return stopbreak();" title="Stop Break">
Stop Break
</button>
</c:if>
</div>
</c:when>
<c:otherwise>
<div class="f-left lf_rt5">
<c:if test="${startclicked !='break'}">
<button type="submit" id="start-break" name="start" value="start-break" disabled="disabled"
type="button" class="actv-btn-dft1 blbg" onclick="return startbreak();" title="Start Break">
Start Break
</button>
</c:if>
<c:if test="${empty stopclicked && startclicked =='break'}">
<button type="submit" id="stop-break" name="stop" value="stop-break" disabled="disabled"
type="button" class="actv-btn-dft1 orbg" onclick="return stopbreak();" title="Stop Break">
Stop Break
</button>
</c:if>
</div>
</c:otherwise>
</c:choose>
<c:choose>
<c:when test="${startclicked=='break'}">
<div class="f-left">
<c:if test="${startclicked !='lunch'}">
<button type="submit" id="start-lunch" name="start" value="start-lunch" disabled="disabled"
type="button" class="actv-btn-dft1 blbg" onclick="return startlunch();" title="Start Lunch">
Start Lunch
</button>
</c:if>
<c:if test="${empty stopclicked && startclicked =='lunch'}">
<button type="submit" id="stop-lunch" name="stop" value="stop-lunch" type="button"
disabled="disabled" class="actv-btn-dft1 orbg" onclick="return stoplunch();"
title="Stop Lunch">Stop Lunch
</button>
</c:if>
</div>
</c:when>
<c:otherwise>
<div class="f-left">
<c:if test="${startclicked !='lunch'}">
<button type="submit" id="start-lunch" name="start" value="start-lunch" disabled="disabled"
type="button" class="actv-btn-dft1 blbg" onclick="return startlunch();" title="Start Lunch">
Start Lunch
</button>
</c:if>
<c:if test="${empty stopclicked && startclicked =='lunch'}">
<button type="submit" id="stop-lunch" name="stop" value="stop-lunch" type="button"
disabled="disabled" class="actv-btn-dft1 orbg" onclick="return stoplunch();"
title="Stop Lunch">Stop Lunch
</button>
</c:if>
</div>
</c:otherwise>
</c:choose>
</c:if>
我有一个出勤系统,有4个按钮StartBreak,STOPBreak和StartLunch,STOPLunch按钮..(在UI中按钮配对即:使用切换按钮 - 相同的按钮用于启动和停止;另一个用于启动和停止午餐)
问题是,一旦开始按钮说单击中断,然后页面刷新,表单再次提交..我不希望这发生..我希望表单不提交开始直到我按停止.. 。 同样如果我按停止按钮 - 然后刷新页面再次提交停止按钮...
我希望我很清楚请注意你的建议......!
答案 0 :(得分:1)
根据我的理解,您的问题是点击按钮后页面加载了两次。将按钮类型更改为"button"
而不是submit
。如果您单击“提交”按钮,表单将自动提交。