如何使用PHP Ajax在使用HTML表单提交多个数据时添加百分比的进度条。
答案 0 :(得分:0)
以下是一个例子:
$(document).ready(function() {
$("input").on("change", function() {
var size = $("input:checked").length;
var progress = size * 10 + "%";
$(".progress").css("width", progress);
});
});
.container {
width: 200px;
height: 30px;
border: 1px solid black;
}
.progress {
height: 100%;
width: 0;
background-color: red;
transition: 0.4s ease;
}
.block {
display: block;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="container">
<div class="progress"></div>
</div>
<form>
<div class="block">
<input id="one" name="one" type="checkbox"><label for="one">One</label></div>
<div class="block">
<input id="two" name="two" type="checkbox"><label for="two">Two</label>
</div>
<div class="block">
<input id="three" name="three" type="checkbox"><label for="three">Three</label>
</div>
<div class="block">
<input id="four" name="four" type="checkbox"><label for="four">Four</label>
</div>
<div class="block">
<input id="five" name="five" type="checkbox"><label for="five">Five</label>
</div>
<div class="block">
<input id="six" name="six" type="checkbox"><label for="six">Six</label>
</div>
<div class="block">
<input id="seven" name="seven" type="checkbox"><label for="seven">Seven</label>
</div>
<div class="block">
<input id="eight" name="eight" type="checkbox"><label for="eight">Eight</label>
</div>
<div class="block">
<input id="nine" name="nine" type="checkbox"><label for="nine">Nine</label>
</div>
<div class="block">
<input id="ten" name="ten" type="checkbox"><label for="ten">Ten</label>
</div>
</form>
对于你的情况:
是否清楚?希望它有所帮助,但由于您没有提供任何代码,因此无法帮助您!