Hi
Is there a way to populate an input box from a selected data table (via a checkbox)? This is the simplistic version. The idea is that the user adds the required number of suppliers and select one (the selection could also be done by a higher level user at a later stage).
Once you select the checkbox for a particular supplier, it is supposed to:
- Unselect a previous selection (if exist)
- Move the selected supplier name to the “Data Row” input box
Not sure why, but the first-row checkbox has to be ticked to get any kind of result which defeats the purpose and is obviously wrong. I can get the id of my selected row (i.e. row 2) but always have to go back to row 1
The classes assigned were:
Data Table = “myTable”
Checkbox section in data table = “dataCbox”
ID for Data Row = “q35”
I started the following code (sorry I know it is still far off - please ignore completely if I’m on the wrong track):
$(document).ready(function() {
$('input[type=checkbox]' && '[class=tableCbox]').click(function(){
$('#q35 input').val("");
getCheckBoxes();
});
var getCheckBoxes = function(){
var result = $('input[type=checkbox]:checked');
if(result.length > 0){
var resultString = result.length
result.each(function(){
var myid = $(this).attr("id");
$('#q35 input').val(myid);
})
}
});
I hope this makes sense.
Thank you for your assistance.
John