Note that there are some explanatory texts on larger screens.

plurals
  1. POAssign value to textbox
    text
    copied!<p>Hi i have a radio button(<a href="http://www.fyneworks.com/jquery/star-rating/" rel="nofollow">StarRating radiobutton</a> using jquery) and a textbox. When i click on the star, i would like the radiobutton value to display to the textbox.</p> <p><code>&lt;input id="InsRating1" class="star" type="radio" name="InsRating" value="1" title="Worst"/&gt;<br> &lt;input id="InsRating2" class="star" type="radio" name="InsRating" value="2" title="Good"/&gt;</code></p> <p>I tried put the Onclick() in the but onClick() has never get fired. Please advice how to get the value from my radiobutton to textbox. Thanks </p> <p>I tried this below, but the value is "Undefined"</p> <pre><code>$(document).ready(function() { $('#InsRating1').click(function() { alert(this.value) }); }); </code></pre> <p><strong>-------------Edit----------</strong><br> I am using g_thom's answer below but come to this problem : I have 3 set of stars with 3 textboxes. Each rating should show to only 1 textbox. However whenever any star is clicked, it shows the value to all 3 textboxes instead of just specified one. Please advice. Thanks</p> <pre><code>&lt;script type="text/javascript"&gt; </code></pre> <p>$(function() {<br> $('.star-rating').click(function() { // assign the value of "total stars" to a textbox with an id of ratingText $('#EvaluationInstructorRatingTextBox').val($('.star-rating-on').length);<br> }); $('.rating-cancel').click(function() { // the value is '0' when the cancel button is clicked $('#EvaluationInstructorRatingTextBox').val('0'); });</p> <pre><code>$('.star-rating').click(function() { // assign the value of "total stars" to a textbox with an id of ratingText $('#EvaluationMaterialRatingTextBox').val($('.star-rating-on').length); }); $('.rating-cancel').click(function() { // the value is '0' when the cancel button is clicked $('#EvaluationMaterialRatingTextBox').val('0'); }); $('.star-rating').click(function() { // assign the value of "total stars" to a textbox with an id of ratingText $('#EvaluationValueRatingTextBox').val($('.star-rating-on').length); }); $('.rating-cancel').click(function() { // the value is '0' when the cancel button is clicked $('#EvaluationValueRatingTextBox').val('0'); }); </code></pre> <p>}); </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload