This must be something utterly stupid that I\'ve done or am doing, but I have an input with a value attribute that simply isn\'t being displayed:
For Googler's who may have the same issue: This can happen if you have a non-numeric value in a number
type input field.
For example:
<input type="number" value="<? echo $myNumberValue; ?> "/>
This will show nothing even though Dev tools says the value is there, since the extra space after ?>
makes it non-numeric. Simply remove the extra space.
For me it was because I was using the <input>
tag without enclosing it inside a <form>
tag
Same problem occured on electron:
I was clearing the field with document.getElementById('_name').value = ''
instead of document.getElementById('_name').setAttribute('value', "")
.
So I guess simple quote broke the field or input has a second value hidden attribute because I could rewrite on the fields and it won't change the value on the inspector
Argh. I knew this was going to be something beyond stupid. There was a bit of Javascript that was clearing data. The clearing was useful in other places, but I didn't know it was executing so it was a serious pain to track down. Once I prevented the clearing in this scenario, my values actually appeared. Because I was looking at the code in web inspector, I assumed that it would be a "live" view, but I guess that's not entirely true.
Thanks for your help, everyone.
For me the problem was that I had multiple inputs with the same id. I could see the value in the field, but reading it via javascript gave an empty value because it was reading a different input with the same id - I was surprised that there was no javascript error, just could not read the values I could see in the form.
Mine was related to AngularJS
I was trying to put both an HTML Value and an ng-Model, thinking that the ng-Model would default to the Value, because I was too lazy to add the Model to the $scope in the Controller...
So the answer was to assign that default value to the $scope.variable in the controller.