<select name="jumpmenu" onChange="jumpChange(this.options[this.selectedIndex].value);">
<option value="">Light 1</option>
<option value="1">Red</option>
<option value="2">Orange</option>
</select>
<script language="javascript">
function jumpChange(sel) {
//var val = sel.value;
var val = sel;
if (val === "") return;
switch(val) {
case '1': var colorred={"on":true,"hue":15331,"sat":121,"xy":[0.1721,0.0500],"ct":343,"transitiontime":100}
case '2':
var colororange={"on":true,"bri":254,"hue":13390,"sat":251,"xy":[0.5663,0.3978],"ct":500, "transitiontime":20} // orange color
break;
}
}
</script>
So I tried this, still not working. Like I showed before, I have this going on on another js file that does work when I hit a button.
HTML file:
<button class="lightbuttontall" onclick="lightcolor(1,colorred);">Light 1 red</button>
Js File:
var xmlhttp
var bridge="192.168.1.2"
var hash="1fe041353d204ca7387f1c0131a8a7d3"
var colorred= "{\"on\":true,\"bri\":255,\"hue\":836,\"sat\":237,\"xy\":[0.6472,0.3316],\"ct\":500}"
var colororange="{\"on\":true,\"bri\":254,\"hue\":13390,\"sat\":251,\"xy\":[0.5663,0.3978],\"ct\":500}"
and then, further down, the functions to do an HTTP PUT command to the Philips hue bridge that is running a json API:
function lightcolor(light,color){
execute('PUT', 'http://'+bridge+'/api/'+hash+'/lights/'+light+'/state', color);
}
Then at the very bottom:
function execute($method,$url,$message){
xmlhttp=new XMLHttpRequest();
xmlhttp.open($method,$url,true)
xmlhttp.send($message);
}
I just don't think I have the right onChange command working. I've confused myself :S