Here are more select examples as they seem popular.
The simple example which was on the other topic
//Simple Select example
var s="";
s+="<select onChange='mango.view.setPoint("+ point.id +", \""+ pointComponent.id +"\", this.options[this.selectedIndex].value )'>";
s+= "<option value=1";
if (value == 1 ) { s+= " selected ";}
s+= "> one </option>";
s+= "<option value=2";
if (value == 2 ) { s+= " selected ";}
s+= "> two </option>";
s+= "<option value=3";
if (value == 3 ) { s+= " selected ";}
s+= "> three </option>";
s+= "<option value=4";
if (value == 4 ) { s+= " selected ";}
s+= "> four </option>";
s+="</select>";
return s;
A generic script for multistate point(uses the text and colour defined in multistate point renderer properties)
//Multi State Select example
//list of states (value key and the text)
var MSList=point.getTextRenderer().getMultistateValues();
var min = 0;
var max = MSList.size();
var s="";
var s2=""; //temporary inside loop, to be able to set the color
//check if list has values
if(max==0){return "No States defined";}
//sanity limit
if(max>100){return "More than 100 states";}
s+="<select ";
for(var i = min; i < max ;i++)
{
s2+= "<option ";
//use the state colours
s2+= "style='color:"+ MSList.get(i).getColour() + "' ";
s2+="value="+ MSList.get(i).getKey() ;
if (value == MSList.get(i).getKey())
{
s2+= " selected ";
//set the select color according to the value
s+= "style='color:"+ MSList.get(i).getColour() + "' ";
}
s2+= "> "+MSList.get(i).getText()+"</option>";
}
s+="onChange='mango.view.setPoint("+ point.id +", \""+ pointComponent.id +"\", this.options[this.selectedIndex].value )'>";
// put the options into the string
s+=s2;
s+="</select>";
return s;
One which is quite easy to modify to some specific need
//Select example with values defined in arrays
//list of the values shown
var choices=new Array("Pint","US gal","UK gal");
//the values for the choices
var values=new Array(0.568,3.785,4.546);
var min = 0;
var max = choices.length;
var s="";
//check if list has values
if(max==0){return "No selections defined";}
//check the array sizes match
if(choices.length!=values.length){return "Array sizes not equal";}
s+="<select onChange='mango.view.setPoint("+ point.id +", \""+ pointComponent.id +"\", this.options[this.selectedIndex].value )'>";
for (var i = min; i < max ;i++)
{
s+= "<option value="+ values*;
if (value == values* ) { s+= " selected ";}
s+= "> "+ choices* +"</option>";
}
s+="</select>";
return s;
BR
-Jokke