ChrisDos Posted April 6, 2020 Share Posted April 6, 2020 I am trying to use a input to get a value of an object. like if I type "sunday" I would get object.sundayCol is there a way to do that? Link to comment Share on other sites More sharing options...
JMRKER Posted April 7, 2020 Share Posted April 7, 2020 How do you plan on getting the input? Are you typing in the word or can it be a button (radio, checkbox or dropdown) selection? Link to comment Share on other sites More sharing options...
Ingolme Posted April 7, 2020 Share Posted April 7, 2020 You can access object properties using square brackets, but you should do a check that the property exists before trying to access it. var day = "sunday"; object[day + "Col"]; Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now