I want add the return value from var Selectedvalue to hidden field id="Branchidhidden" in its value.
jQuery:
function Branch() {
var Selectedvalue = $( "#Branchitemtypeid option:selected" ).val(); //The return value is correct
$('#Branchidhidden').attr('value', Selectedvalue)
}
HTML:
<input type="hidden" id="Branchidhidden" name="Branchidhidden" value=""/>
When I see the view-source value in hidden field is empty.
valueattribute:.attr('value', Selectedvalue)This is a duplicate question..val(yourValue)on that input, but remove thevalue=""attribute from hidden input tag