问题描述
我有一个home.php页面,在其中我从load_posts.php加载带有Ajax函数的帖子 这是load_posts.php的重要代码:
...
$userid = $_POST['userid'];
$sql = mysqli_query($conn,"SELECT * FROM storie WHERE userid IN (SELECT following FROM follow WHERE follower='$userid')");
while($row = mysqli_fetch_assoc($sql)){
$idsto=$row['storia_id'];
...
?>
<div class="storia" id="storia_<?php echo $idsto;?>">
...
<div class="star-rating">
<input id="star-5" type="radio" name="rating" value="5" class="stellette" />
<label for="star-5" title="5 stars">
<i class="active fa fa-star fa-sm" aria-hidden="true"></i>
</label>
<input id="star-4" type="radio" name="rating" value="4" class="stellette"/>
<label for="star-4" title="4 stars">
<i class="active fa fa-star fa-sm" aria-hidden="true"></i>
</label>
<input id="star-3" type="radio" name="rating" value="3" class="stellette"/>
<label for="star-3" title="3 stars">
<i class="active fa fa-star fa-sm" aria-hidden="true"></i>
</label>
<input id="star-2" type="radio" name="rating" value="2" class="stellette"/>
<label for="star-2" title="2 stars">
<i class="active fa fa-star fa-sm" aria-hidden="true"></i>
</label>
<input id="star-1" type="radio" name="rating" value="1" class="stellette"/>
<label for="star-1" title="1 star">
<i class="active fa fa-star fa-sm" aria-hidden="true"></i>
</label>
</div>
</div>
<?php
}
?>
我想有两个jQuery变量,一个具有$ idsto等级的值,另一个具有1到5的等级检查值。
当我在一个页面中只有一个评分时,只需执行以下操作:
$('input[name=rating]').change(function(){
var voto = $( 'input[name=rating]:checked' ).val();
但是现在我不知道如何获得ID $ idsto的特定等级。 我尝试编写此代码,但没有结果:
$("input[name^='rating']").change(function(){
...
name="rating_<?php echo $idsto;?>"
有人可以帮助我吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)