I am currently trying to build up some html via javascript and when I try to assign the value attribute of my textarea input control it does not seem to want to pull through, the textarea becomes blank when loaded. Values seem to pull through for normal text type input. I have also stepped through the javascript code and made sure the JSON data I was getting actually had a value in it, which it did.
function BuildDeviceInfoHTML(data) {
var divFormGroupOpening = '<div class="form-group">';
var divOpeningInput = '<div class="col-md-10">'
var result;
var deviceName = divFormGroupOpening + '<label class="col-md-2 control-label" for="deviceName">Device Name: </label>' +
divOpeningInput +
'<input id="deviceName" class="form-control" type="text" value="' + data.devices[0].deviceName + '" name="deviceName" data-val-required="Device name is required" data-val="true">'
+ '</div></div>';
var deviceDisplay = divFormGroupOpening + '<label class="col-md-2 control-label" for="deviceDisplay">Displayed as: </label>' +
divOpeningInput +
'<input id="deviceDisplay" class="form-control" type="text" value="' + data.devices[0].deviceDisplay + '" name="deviceDisplay" data-val="false">'
+ '</div></div>';
var deviceDesc = divFormGroupOpening + '<label class="col-md-2 control-label" for="deviceDisplay">Displayed as: </label>' +
divOpeningInput +
'<textarea id="deviceDesc" class="form-control" value="' + data.devices[0].deviceDesc + '" name="deviceDesc" data-val="false"></textarea>'
+ '</div></div>';
result = deviceName + deviceDisplay + deviceDesc;
return result
}
Textarea hasn't
value
attribute. You should put content inside tag:You should modify last part of your code in: