简体   繁体   中英

Select a row from data table to show radio button value

I have the data table and when i select a row from it, All value shows in input text field without radio button. here is the delegate function

$('#itb tbody').delegate('tr', 'click', function(){
        $("#SCC23_STATIONNAME").val($("td:eq(0)", this).text());
        $("#SCC23_DEPSTATION").val($("td:eq(1)", this).text());
        return false;
    });

If i have radio button as like

<tr><td>PROCEDURE TYPE  : </td>
                    <td><input type='radio' rel="2" name="SCC23_PROCTYPE" id="SCC23_PROCTYPE[]" value="ASSEMBLY">ASSEMBLY
                    <input type='radio' rel="2" name="SCC23_PROCTYPE" id="SCC23_PROCTYPE[]" value="SMT">SMT
                    </td>
                </tr>

How can i found the value of radio button when select a data table row?

Use prop function; something like $("input[name=background][value='some value']").prop("checked",true); Check here.

https://jsfiddle.net/hvz8zq6j/5/

fiddle: https://jsfiddle.net/hvz8zq6j/1/

$('table').on('click', 'tr', function(e){

  var vals = $('input', this).map(function(){
    return this.value;
  }).get();

  alert(vals.join());
});


$('input', this) get all the input elements in the row

.map(function(){return this.value;}).get(); get an array of their values

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM