[英](PHP) Button clicking counter on Cloning button
I'm new to PHP. 我是PHP新手。 Now I have a problem about how to count how many times I click on Cloning field button. 现在我有一个关于如何计算单击“克隆”字段按钮的次数的问题。
This is my codes so far. 到目前为止,这是我的代码。
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<?php
include('DBconnect.php');
mysql_query("USE onlinerecruitment");
$counter = 0;
$result = mysql_query("SELECT * FROM position WHERE Position_Recruit_Status = '1'");
?>
<form method="POST" action="confirm-weight-score-setup.php">
<div id="main_wrap">
Weight Score Set up
<br><br><font color="red">*Total Skill weight Must be equal to 10</font>
<br><br>Position :  
<SELECT name='position'>
<?php
while ($rows = mysql_fetch_array($result)) {
echo "<option value='" . $row["Position_ID"] . "'>" . $row["Position_Name"] . "</option>";
}
?>
</SELECT>
<button onClick="history.back()";> Back </button>  
<input type="submit" name="confirm" value="Submit">
<!-- + button -->
<div id="clone" >
<br><br>Skill name <input type="text" name="skill_name[]"/>  
Skill weight (Not more than 10) <input type="number" name="skill_weight[]" min="0.0" max="10.0" step="0.1" value="0.0">
</div>
<!-- + button -->
<div style="float:right;">
<input type ="button" value="+" name = "more" id="more" style="float:right;">
</div>
</form>
</div>
<script>
$(document).ready(function () {
$("#more").click(function () {
$("#clone").clone().appendTo("#main_wrap");
});
});
</script>
This is button part that I want the counter to count how many times users click on this button 这是按钮部分,我希望计数器计算用户单击此按钮的次数
<!-- + button -->
<div style="float:right;">
<input type ="button" value="+" name = "more" id="more" style="float:right;">
</div>
I have no idea what I have to do, I tried to search this issue but found only POST
button answer not "Button on click" so I don't know how to do it and where I have to place the codes. 我不知道该怎么办,我尝试搜索此问题,但是发现只有POST
按钮的答案,而不是“ Click on click”,所以我不知道该怎么做以及必须将代码放置在什么地方。
To count clicks 计算点击
$(document).ready(function () {
var clicks = 0;
$("#more").click(function (e) {
if(clicks >= 10) {
e.preventDefault();
return false;
}
$("#clone").clone().appendTo("#main_wrap");
clicks += 1;
});
});
To store clicks in hidden input 将点击存储在隐藏的输入中
<input type="hidden" name="clicks" id="clicks">
Modify the jquery... 修改jQuery ...
...
clicks += 1;
$('#clicks').val(clicks);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.