akhanisatyammg / jquery-star-rating-plugin

Automatically exported from code.google.com/p/jquery-star-rating-plugin
0 stars 0 forks source link

how to dynamic choose checked rating #52

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.the codes are just like below 
2.if i click getpicture button ,i can't get value
3.but if i put this code 
$("#star3 input:lt("+t+")").attr("checked","checked")
just in 
$(document).ready(function(){ .......  }) by delete
$("#btn").click(function(){..})
i can get the value that i need. 

What is the expected output? What do you see instead?

so i need the dynamic function like this api($().rating('select', index /
value))

What version of the plugin/jQuery are you using?
PLUGIN VERSION:latest version
JQUERY VERSION:1.32

On what browser(s) or operating system?
BROWSER(S):firefox3.5

Feel free to provide any additional information below.

<html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<script type="text/javascript" src="jquery.js"></script>
<script language="javascript" type="text/javascript"
src="jquery.MetaData.js"></script>
<script type="text/javascript">

$(document).ready(function(){ 

$("#btn").click(function(){
//t is used to get the value of first rating value plus second rating value
divide 2 
var t=0
var x=$(this.form).serialize()
var x=x.split("&")
for(var i=0;i<x.length;i++){
var y=x[i].split("=")
y[1]=parseInt(y[1])
t=parseInt((t+y[1])/2)
} 

$("#star3 input:lt("+t+")").attr("checked","checked")

})

})

</script>
<script language="javascript" type="text/javascript"
src="jquery.rating.js"></script>
<link rel="stylesheet" type="text/css" href="jquery.rating.css">
</head>
<body>

<form name="form1" id="form1">
<p>star1</p>
<input name="star1" type="radio" class="star" value="1"/>
<input name="star1" type="radio" class="star" value="2"/>
<input name="star1" type="radio" class="star" value="3"/>
<input name="star1" type="radio" class="star" value="4"/>
<input name="star1" type="radio" class="star" value="5"/>
<br>
<p>star2</p>
<input name="star2" type="radio" class="star" value="1"/>
<input name="star2" type="radio" class="star" value="2"/>
<input name="star2" type="radio" class="star" value="3"/>
<input name="star2" type="radio" class="star" value="4"/>
<input name="star2" type="radio" class="star" value="5"/>

<br>

<input type="button" value="getvalue" onclick="$(this).next().html(
$(this.form).serialize() || '(nothing selected)' );   " >
<span></span>
<input type="button" value="getpicture" id="btn">
<div id="star3">
<input  name="star3" type="radio" class="star {split:5}" value="1"
disabled="disabled"/>
<input  name="star3" type="radio" class="star {split:5}" value="2"
disabled="disabled"/>
<input  name="star3" type="radio" class="star {split:5}" value="3"
disabled="disabled"/>
<input  name="star3" type="radio" class="star {split:5}" value="4"
disabled="disabled"/>
<input  name="star3" type="radio" class="star {split:5}" value="5"
disabled="disabled"/>
</div>
</form>
</body>
</html>

Original issue reported on code.google.com by sheng.yo...@gmail.com on 22 Jan 2010 at 12:33

GoogleCodeExporter commented 8 years ago

Original comment by diego.a...@gmail.com on 23 Feb 2013 at 5:12