-1

I am trying to create a function that dynamically sets properties based on parameters,

it looks like this

function setPro(sourceId,type,destId){
    document.getElementById(destId).style. + type = document.getElementById(sourceId).value;

}

I'm not sure what to do on setting the type?

is this possible? or am I going to have to do a select case and choose based on that?

0

1 Answer 1

7

You can use [] notation:

document.getElementById(destId).style[type] = document.getElementById(sourceId).value;
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.