Welcome Guest, Not a member yet? Register   Sign In
Star Rating + Codeigniter
#1

[eluser]alexaaaaaaaaaa[/eluser]
Hi i've just implemented into one of my projects stars rating and it's working finally...
here's the code

view
Code:
[removed]
$(function(){

$('#form3 :radio.star').rating();

});
[removed]
  
      <form id="form3A" />

      <?php foreach($polls_choices as $polls_choice) { ?>
    <p> &lt;?php echo $polls_choice->choice;  ?&gt;
    <div >
        &lt;input class="&lt;?php echo $polls_choice-&gt;id; ?&gt;" type="radio" name="&lt;?php echo $polls_choice->id; ?&gt;" id="auto-submit-star" value="1"/>
        &lt;input class="&lt;?php echo $polls_choice-&gt;id; ?&gt;" type="radio" name="&lt;?php echo $polls_choice->id; ?&gt;" id="&lt;?php echo $polls_choice->choice; ?&gt;" value="2" />
        &lt;input class="&lt;?php echo $polls_choice-&gt;id; ?&gt;" type="radio" name="&lt;?php echo $polls_choice->id; ?&gt;" id="&lt;?php echo $polls_choice->choice; ?&gt;" value="3"/>
        &lt;input class="&lt;?php echo $polls_choice-&gt;id; ?&gt;" type="radio" name="&lt;?php echo $polls_choice->id; ?&gt;" id="&lt;?php echo $polls_choice->choice; ?&gt;" value="4"/>
        &lt;input class="&lt;?php echo $polls_choice-&gt;id; ?&gt;" type="radio" name="&lt;?php echo $polls_choice->id; ?&gt;" id="&lt;?php echo $polls_choice->choice; ?&gt;" value="5"/>
       </div>
    <br/>
        &lt;  script &gt;
$(function(){
$('.&lt;?php echo $polls_choice->id; ?&gt;').rating({

  callback: function(value, link){
  
    $.getJSON('index.php/poll/ajax_rating/' + value + '/' + &lt;?php echo $polls_choice->id; ?&gt; + '/' + &lt;?php echo $this->uri->segment(3); ?&gt; + '/' + &lt;?php echo $account->id; ?&gt;);
  }
});
});


< / script >


controller
Code:
function ajax_rating($rate_id)
    {
    echo $rate_id. " " .$this->uri->segment(4). " " .$this->uri->segment(5). " " .$this->uri->segment(6);
    
    }

For js files and documentation here http://www.fyneworks.com/jquery/multiple...b-Examples

No spam just if there's someone asking how to implement this i'll be glad to guide him as much as i can.
Regards,
Alex
PS. use if(IS_AJAX){ ..insert data } else { redirect what ever you want to do} just a small security thing and after you submit the rating you can easy hide ans show a div with the results what ever you want ...




Theme © iAndrew 2016 - Forum software by © MyBB