when i alert the array, he return the hole value, but when i try to get it from getElementById, he stop after the first space!??
I know, it's probably simple, but i dont understand the difference between the 2 answers
https://jsfiddle.net/prodeinfo/jvywho3y/
html
<div>
<div id="statusList"></div>
</div>
javascript
var countryLan = ["nothing","Also nothing",];;
alert(countryLan[1]);
document.getElementById('statusList').innerHTML += "<input type='text' value=" + countryLan[1] + " />";
Try this:
as you can see, I added
'
invalue
:value='" + countryLan[1] + "' />"
You had a problem because if you want to pass a text that contains spaces, you need to quote this text properly. In your case, you just put the value from an array as is, without quotes and that's why there was only "Also" in your input.
Now it should work. Good luck.