View Full Version : Resolved Trying to use drop down menu to display a colour for system status

Fat Bambi
06-23-2009, 06:40 PM
Iím creating a webpage that will display the status of various IT systems on a large screen. The users will be helpdesk staff who will need to change the statuses of the various systems. Maybe I am approaching this in the wrong way but I thought I could use a drop down menu to enable the helpdesk to select the system status which would be either: Green, Amber or Red. I have managed to hack the following code by using something I found on the web. It almost does what I want but on selecting the colour from the drop down menu it tries to load another page. Is there any way I can stop it from doing this? The webpage should be static and I am aware that reloading it would lose any selections that the user has made.

Thanks for your help. Here is the code:

<select onChange="location=this.options[this.selectedIndex].value;" style="font-family:'Arial';color:#00CC00;background-color:#00CC00;font-size:10pt;">
<option value="GREEN">UP</option>
<option style="font-family:'Arial';color:#FF9900;background-color:#FF9900;font-size:10pt;" value="RED">DOWN</option>


Philip M
06-23-2009, 06:59 PM
Is this what you want?

<select id = "s1" onchange = "go()">
<option value = "" selected>Select a status</option>
<option value = "Red" style="background-color: red; color: white;"> RED<br>
<option value = "Amber" style="background-color: orange; color:white;"> AMBER<br>
<option value = "Green" style="background-color: green; color:white;"> GREEN<br>


<script type = "text/javascript">
function go() {
var val = document.getElementById("s1").value;
if (val !="") {
alert ("You selected option value:- " + val);


<select onChange="location=this.options[this.selectedIndex].value;
is attempting to redirect to a new page. You have copied the script rather blindly as this is not what you want.

"Most of the time I don't have much fun. The rest of the time I don't have any fun at all." - Woody Allen - US movie actor, comedian, & director (1935 - )

Fat Bambi
06-23-2009, 07:20 PM
Thanks Phil. That was what I wanted it to do. I removed the pop up window and copied the menu as many times as was needed. That has realy helped me out a lot. thanks again.