I have a dropdown that contain a list of people which contain also a unique id number like for example data1
contain ID = 5
. How the ID of 5 pass to the hidden field?.
I'm having trouble understanding on how / where / when to use the hidden field like this
<input type="hidden" id="hidPersonId" />
I'm always asking myself how the hidden field has the value when a scenario is adding a data. How did the hidden field get the value or ID. Please explain to me how did that happen if possible step by step?. Thanks.
hidden fields
are made in .cshtml
view of the page. Like in your example how did the hidden field get the ID of 5?. After the event of change(choose from the dropdown)
the ID is pass to the hidden field. For example
This event is on change function.
var drpSample = $("#drpID").val(); //--- let say the ID is 5
$("#hidPersonId").val(drpSample);