gowtham gowtham - 2 months ago 4x
Vb.net Question

Need to enter value in text field on label where value from input tag

I need to get value attribute from this table data id="q5" from input tag on click anyone of the radio button and show it label which id=R1 is it possible???

for example if i click radio button 4 that button value 4 should be return to label text

<asp:Label ID="Q5" CssClass="lb1" runat="server"></asp:Label>
<td class="rating" id="Q5">
<input type="radio" id="qs55" name="rating" value="5" /><label class="full" for="qs55" title="Awesome - 5 stars"></label>
<input type="radio" id="qs54" name="rating" value="4" /><label class="full" for="qs54" title="Pretty good - 4 stars"></label>
<input type="radio" id="qs53" name="rating" value="3" /><label class="full" for="qs53" title="Average - 3 stars"></label>
<input type="radio" id="qs52" name="rating" value="2" /><label class="full" for="qs52" title="Poor - 2 stars"></label>
<input type="radio" id="qs51" name="rating" value="1" /><label class="full" for="qs51" title="Very Poor - 1 star"></label>
<asp:Label ID="R1" runat="server"></asp:Label></td>

if possible please explain



You can get the next label's title property and assign it to R1:

$(function() {
    $("input[type=radio").change(function() {

Note that you have tr in your question, so it's safe to assume you will have multiple questions with ratings - so the "#R1" code will only set one of them, you can get around this with:

$("#R1", this.closest("tr")).text($(this).next("label").prop("title"))

however, you're also using <asp:label and Q5 so I'm guessing this should be R5 and will change to allow postback.

Here's a working fiddle with multiple rows, but I'll leave it to you to change the ID of R1 as there should only be one element with a specific ID: https://jsfiddle.net/xprrxgef/