【发布时间】:2014-01-06 07:07:49
【问题描述】:
在我的 mvc 应用程序中,我使用raty 对我的图像进行评级。这是我的代码
<div class="container">
<form method="post" class='form' role='form' action="?section=photo&view=addVote">
<input type="hidden" name="photoId" value="<?php echo $photoinfo['id']; ?>"></input>
<input type="hidden" name="score" value="<?php ?>"></input>
<div class="row">
<div>
<img src="<?php echo base_url(); ?>images/photo_booth/<?php echo $photoinfo['image_name'];?>" class="img-rounded img-define" width="580" height="350"></img>
</div>
<div>
<h6><?php echo $photoinfo['title'] ?></h6>
</div>
<div>
<p class="paragraph"><?php echo $photoinfo['description'] ?></p>
</div>
<div>
<div id="raty"></div>
<button type="submit" class="btn btn-primary button_new submit-btn">Add Vote</button>
</div>
</div>
</form>
<script type="text/javascript">
$('#raty').raty({
score: <?php echo $photoinfo['vote']; ?>,
number: 10,
starOn: "<?php echo base_url(); ?>icons/star-on.png",
starOff: "<?php echo base_url(); ?>icons/star-off.png",
readOnly: false
});
$("#raty > img").click(function(){
var score=$(this).attr("alt");
});
</script>
在这里,我可以使用 javascript 将我的 score=$(this).attr("alt"); 保存到数据库。但我需要将其作为隐藏字段数据传递,类似于<input type="hidden" name="score" value="<?php the score of raty! ?>"></input>
。这里 addVote 是我必须执行操作的方法。
我可以这样做吗?如果存在另一种方式,那怎么办?谢谢。
【问题讨论】:
-
我只是将一个id添加到隐藏字段并将其添加到javascript中,解决了。
标签: javascript php model-view-controller raty