If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Running Script onChange using Options

Hey there,

Been lurking a bit and couldn't find the answer. Basically I have a bunch of buttons that I want to turn into a drop down menu and have the code be executed onChange. But, I'm a javascript n00b and am having a hard time figuring out how this would work. I somewhat got it to work, but I couldn't get it to work with more than one option.
Here's what I have:

Works awesome! Now my next step is to see if I can a dropdown to control the light color. I have been banging my head against my desk trying to figure this out for the past 4 hours. I'm sure it's something really stupid as well. I have a variable, and some options, I basically just want

Code:

"lightcolor(1,colorred);"

to not JUST be 1,colorred, but rather I want it to grab whichever option I select and replace it with the corresponding option. Example:

So I have my drop down and if I had selected red, the onChange = "light color(1,colored);"> now would work. But if I select orange, it turns into onChange="light color(1,color orange);">. I have these variables in a js file that it's pulling from that are named colorred,orange,blue etc.

I can definitely show my attempts, but just a warning, they're pretty bad haha. I don't have a link because it runs off of my home network and actually changes my lights. Ill dig up some other attempts.

Now, it only changes to the color blue, becuase it's basically saying "any time this changes, turn the light to the color blue". but I don't know how to make it so that the "onChange" can be changed to let's say "lightcolor(1,colorred);" or "lightcolor(1,color pink);" dependent upon the option that I choose.

You, sir, are a saint. You have no idea how much I really do appreciate your help. I didn't want to be the choob that gets on here, gets his code and bails, thus I wanted to make sure you guys knew I was actually trying! I will do that. I'll let you know how it goes. Thanks again!

You, sir, are a saint. You have no idea how much I really do appreciate your help. I didn't want to be the choob that gets on here, gets his code and bails, thus I wanted to make sure you guys knew I was actually trying! I will do that. I'll let you know how it goes. Thanks again!

You are most welcome.
Happy to help, if I can.
Keep us posted and Good Luck!