Link to home
Start Free TrialLog in
Avatar of huzefaq
huzefaq

asked on

how to compare object values in javascript

hi guys

I have this code alert(selectField.name); prints out shipping_country in the alert box

Now when i try to compare this in an if statement like this
if(selectField.name == "shipping_country"){
alert("executed");
}

it gives an error
Object expected

Would anyone know what is teh correct way to compare the value in teh if statement. Thanks
ASKER CERTIFIED SOLUTION
Avatar of Zyloch
Zyloch
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of huzefaq
huzefaq

ASKER

You are right it is correct. I just did a small type. Thanks