-2

I have the following input

<input id="result" ng-model="upload.documentURL" type="text" name="recievedDate"> <br></form>

where the id="result" refers to the javascript line that would provide the input its value

 var message =  url;
    document.getElementById('result').innerHTML = message;

In other words, I want the value of the input to refer the message provided written in the javascript line.

However, I am not sure how to achieve this.Any help would be greatly appreciated.

Liam
  • 27,717
  • 28
  • 128
  • 190
Jon
  • 119
  • 2
  • 10

2 Answers2

4

You can not use innerHTML for the input type. If you have to set the value for the input then you have to use the follwing code :

var message =  url;

document.getElementById('result').value = message;
Liam
  • 27,717
  • 28
  • 128
  • 190
kelvinb
  • 41
  • 4
0

input tags do not conatin any text content. innerHTML is not helpful. input tags use a value attrubute instead:

<input id="result" value="foo">

And so your JavaScript to adgust that argument:

document.getElementById('result').value = url;
Sukima
  • 9,965
  • 3
  • 46
  • 60