PHP,PHP循环中的JAVASCRIPT
我目前从事投票系统的工作。每次选民选择候选人时,javascript都应该工作,但什么也没发生。这是我的密码PHP,PHP循环中的JAVASCRIPT,javascript,php,Javascript,Php,我目前从事投票系统的工作。每次选民选择候选人时,javascript都应该工作,但什么也没发生。这是我的密码 <?php while ($row = $stmt->fetch()) { ?> <div class="form-group"> <div class="row"> <label class="control-label col-md-3 col-md-push-1" id="lab
<?php while ($row = $stmt->fetch()) { ?>
<div class="form-group">
<div class="row">
<label class="control-label col-md-3 col-md-push-1" id="labelpad" for="username"><?php echo $row['position']; ?></label>
<div class="col-md-6 col-md-push-0"><br>
<?php
$stmt1 = $con->prepare("SELECT * FROM candidate WHERE position = ?");
$stmt1->bindParam(1, $row['position']);
$stmt1->execute();
while ($row1 = $stmt1->fetch())
{
?>
<label>
<input id="" class="uniform_on" name="selector[]" type="checkbox" value="<?php echo $row1['candidate_id'];?>">
</label>
<?php echo "<label>".$row1['name']."</label>"; ?><br>
<script>
$(".uniform_on").change(function(){
var max= <?php $row1['vote_limit'];?>
if( $(".uniform_on:checked").length == max {
$(".uniform_on").attr('disabled', 'disabled');
alert('5 Items allowed per borrow');
$(".uniform_on:checked").removeAttr('disabled');
}else{
$(".uniform_on").removeAttr('disabled');
}
})
</script>
<?php } ?>
</div>
</div>
$(“.uniform_on”).change(函数(){
var max=
如果($(“.uniform\u on:checked”)。长度==最大值{
$(.uniform_on”).attr('disabled','disabled');
警报(“每次借用允许5项”);
$(“.uniform_on:checked”).removeAttr('disabled');
}否则{
$(“.uniform_on”).removeAttr('disabled');
}
})
如果你想要AJAX类型的功能,你至少有3个独立的层来放置调试输出,4个。我的建议是首先在每个PHP、JS和数据库调用周围放置一些调试语句,看看它们在哪里执行,在哪里不执行。你熟悉我说的这类事情吗?我看到了“投票限制”这是主要问题。您希望如何使用投票限制?它会限制每个复选框组每个用户的投票量,还是会限制整个投票的投票量(即使是不同的职位)?候选人只属于一个职位,还是可能有相同的候选人担任多个职位?@Bryan您在吗?