hunterzzpro hunterzzpro - 2 years ago 77
Javascript Question

object with array type string causing a typeError

The best way to explain this is just to show you.

var condition = 70;
var formnames = new Array("wheelcheckbox1", "wheelcheckbox2","spokecheckbox","spokecheckbox2","tirecheckbox","tirecheckbox2","tirecheckbox3");

formnames.forEach(function(entry) {
if(obj.entry == "") {
condition = condition - 10;

as you can see i used the console log to show how it needs to work
as that works perfect, however using the array causes an error as
they're strings and not what the obj wants, it wants text without it being a string if you get what i mean, any ideas?

Answer Source should not be used to iterate over an array. Consider using forEach instead.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download