Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 years ago.
Improve this question
Hi I'm trying to print a list in which every entry should look like "element X of TOTAL" but instead of TOTAL i get only blank text.
I fell like it's something stupid but i can't figure out what.
This is from my html
<li ng-repeat="elem in lista" ng-show="check">
Elemento {{elem.item}} di {{len}}
<button ng-click="remove(elem)">Remove</button>
</li>
and here is from my app.js, which includes my controller
$scope.lista = [
{ item: 'uno' },
{ item: 'due' },
{ item: 'tre' }
];
var len = $scope.lista.lenght;
Change
var len = $scope.lista.lenght;
To :
$scope.len = $scope.lista.length;
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 months ago.
Improve this question
Consider this simple attempt to find a value in an object:
var config = {
product1: {
ids: ['master']
},
product2: {
ids: ['ps1', 'ps2']
}
};
var id = 'ps2';
var slotID = 'master';
var categorySlotIds = config[slotID].ids;
categorySlotIds.find(id);
I get: TypeError: Cannot find function find in object product1, product2
If I do typeof(categorySlotIDs) the result is object.
The manual for find says: The find() method returns the first element in the provided array
What gives?
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
I'm just trying to get the nav buttons to stay colored 'onclick'. I don't understand why it won't work... Can anyone help?
const about = document.getElementById('about-btn');
about.addEventListener ('click' () => {
about.style.backgroundColor = "#AAE0CE";
});
You have white spaces, which should give you errors anyways:
const about = document.getElementById('about-btn');
about.addEventListener('click', () => {
about.style.backgroundColor = "#AAE0CE";
});
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 3 years ago.
Improve this question
Trying to displaying individual elements of staff variable in javascript displays undefined in console
<script>
var staff = {"stdinfo" :{"si": "HH01", "sn":"DAVE BAN", "sc":"HGT 1 ", "scid":"44"},"stdinfo1" :{"si": "HH16", "sn":"DEOR ORIE MAR", "sc":"JHT 3", "scid":"31"}};
</script>
console.log(staff.stdinfo0.si) displays undefined. What am I doing wrong?
Your confusing stdinfo with stdinfo0, It's missing the curly brackets, and it has an extra ".
var staff = {
"stdinfo0": {"si": "HH01", "sn":"DAVE BAN", "sc":"HGT 1 ", "scid":"44"},
"stdinfo1": {"si": "HH16", "sn":"DEOR ORIE MAR", "sc":"JHT 3", "scid":"31"}
};
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
var data = {};
data.info.id = "alpha";
This logs to the console: "TypeError: data.info is undefined".
Well that's great and all but I need to store a value in data.info.id. Isn't that what objects are supposed to do?
This should produce an object that looks like this:
data: {
info: {
id: "alpha"
}
}
Is data.info = {} really a necessary step?
In response to Patrick Evans - that's an unrelated question.
Well there is another way. That's putting the info-object directly in the data-object like this:
var data = {
info: {}
}
data.info.id = "alpha";
console.log(data);
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
This code should working, but I have no idea why it is not working at all.
HTML:
<p><input type="file" size="50"></p>
<p><input type="button" value="test" onclick="test()"></p>
JavaScript:
test = function() {
console.dir(document.querySelector('input[type="file"]').value);
var a = document.querySelector('input[type="file"]').vaule;
console.dir(a);
};
The first console.dir can successfully display the selected file filename
whereas I store it in var a is return undefined, whats happended?
fiddle: jsfiddle.net/eb5tuo7o
With the console log you're using .value but when you're storing it you've misspelled it as .vaule.
test = function() {
console.dir(document.querySelector('input[type="file"]').value);
var a = document.querySelector('input[type="file"]').value;
console.dir(a);
};
There is no such thing as "vaule"
You can access html elements value by using
document.querySelector('input[type="file"]').value;
And if you are using jquery it's even simpler
$("input[type=file]").val();