javascript - How to insert selected radio button value into table cell -
i have 5 radio buttons
<input type="radio" id="rating">1 <input type="radio" id="rating2">2 <input type="radio" id="rating3">3 <input type="radio" id="rating4">4 <input type="radio" id="rating5">5
i have 1 table
<table id="mytabledata" border="1" style="width:100%"> <tr id="templaterow"> <th>ratings</th> </tr> </table>
one add button
<input type="button" id="add" value="add" onclick="addradiovalue()">
i've written code dynamically add rows table, when select radio button , click on add button, value of selected radio button should inserted new cell within table ratings.
i able thing text box, i'm not able radio button. can me?
your problems didn't have name
set on radios , trying grab selected radio id statement. need grab radio elements name , loop check selected.
working jsfiddle: http://jsfiddle.net/cv4u0nf9/4/
the loop inserted
var ratings = document.getelementsbyname("rating"); (var i=0; i<ratings.length; i++) { if (ratings[i].checked) { rating = ratings[i]; } }
Comments
Post a Comment