I've an action button which opens a modal when clicked, that button has a value attribute named blockNo with a value. Now I want to capture that value and insert it into a text field in the modal which opens when the button is clicked.
The Button
<button class="btn btn-info btnAddADM" idMark="'.$value["id"].'" blockNo="'.$value["blockNo"].'" data-toggle="modal" data-target="#addADM"><i class="fa fa-sort-numeric-asc"></i></button>
The Input field on the modal
<input class="form-control input-lg" type="text" id="newBlock" name="newBlock" value="" readonly>
Thanks
*Edit1
The Page
the page contains data loaded from the database and each row has 3 buttons to edit, insert new data & delete respectively. The question here is about the middle button which opens a modal to insert data into new table in the database.
now in the first field which is blank in the picture i want to capture block no from the table and insert it automatically, coz it is the id field. After applying the solution given by Rohit it worked only for the first row button and for other row buttons sometimes takes first row's block no and sometimes its blank. I want it to display respective rows block nos.
javascript file code
$(document).ready(function(){
$("#btnAddADM").click(function(){
$("#blockNo").val($(this).attr("blockNo"));
});
});
button code
<button class="btn btn-info btnAddADM" id="btnAddADM" idMark="'.$value["id"].'" blockNo="'.$value["blockNo"].'" data-toggle="modal" data-target="#addADM"><i class="fa fa-sort-numeric-asc"></i></button>
input field code
<input class="form-control input-lg" type="text" id="blockNo" name="blockNo" readonly required>