0

I have a problem with javascript. I have downloaded a rating star plugin , this one to be exact: http://www.fyneworks.com/jquery/star-rating/#tab-Testing

I have multiple things to rate on one page, so i thought i could use an onclick to send it to a function, that sends it to my database with ajax. The problem is, when a rating star is clicked nothing happens, ive tried it on a regular submit button and the function gets executed.

Here is the code :

            <script type="text/javascript">
               function postform(){                      
                           alert('Thing is clicked');
                       };                 
            </script>

And the star is actually a radio button:

<input name="adv1" type="radio" class="star {split:4}" value="0.50" onclick="postform()"/>

I can't see what is wrong with the code, because when i test it on a regular button like this :

 <input type="submit" value="testbutton" onclick="postform()"/>

It gives me the alert Thing is Clicked.

Somehow the star doesn't like the onclick stuff.. Ive tested it in IE, Chrome and FF, nothing ever happens

could someone help me out here?

Thanks alot!

Edit:

As requested by Lukas , i have this in my head :

<script type='text/javascript' src='jquery.min.js'></script>
<script src='jquery.MetaData.js' type="text/javascript"></script>
<script src='jquery.rating.js' type="text/javascript"></script>
1
  • Could you also provide the code where you're initiating the plugin on the given elements? Commented Jan 10, 2013 at 22:10

1 Answer 1

2

That library is handling the onclick event of the radio button for you, so you cannot handle it by adding an attribute onclick to the input element.

According to their documentation you need to put some code like this in a script:

$('.auto-submit-star').rating({
    callback: function(value, link){
        alert(value);
    }
});

Then add the class auto-submit-star to the class list of your radio button:

<input name="adv1" type="radio" class="auto-submit-star {split:4}" value="0.50" onclick="postform()"/>
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks i will try this out now! Ill let you know in 5 minutes
Can't get it to work yet but you pointed me into the right direction! Im sure ill figure it out now. Thanks alot!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.