Copy link to clipboard
Copied
Hi - I have a button on a form which will change color based on a selection from a pop up menu activated by clicking the button. So, click the button, select one of the 5 options and depending on the option selected the entire button will fill with a set color.
I have been able to create the pop up menu as I need it, but I cannot get the resulting action (color change) to work. New to this so would appreciate your help getting the final piece to work. Thanks.
var c = {
'Home':['1,0,0'],
'Motor':['0,176/255,80/255'],
'Marine':['84/255,141/255,212/255'],
'Commercial':['246/255,132/255,38/255'],
'Home Essentials':['1,128/255,1'],
}
var n = new Array('Type of loss:');
for (var i in c) n.push(i);
var result = app.popUpMenu(n);
if (result) {
this.fillColor = ["RGB",c[result]];
}
Copy link to clipboard
Copied
There are several issues with your code... Use this one instead:
var c = {
'Home':["RGB", 1,0,0],
'Motor':["RGB", 0,176/255,80/255],
'Marine':["RGB", 84/255,141/255,212/255],
'Commercial':["RGB", 246/255,132/255,38/255],
'Home Essentials':["RGB", 1,128/255,1],
}
var n = new Array('Type of loss:');
for (var i in c) n.push(i);
var result = app.popUpMenu(n);
if (result) {
event.target.fillColor = c[result];
}
Copy link to clipboard
Copied
This is very helpful. Thanks so much for following me to this post!
Copy link to clipboard
Copied
Do you need the menu to be two levels deep?
This small change will create a menu with one level.
var c = {
'Home':['1,0,0'],
'Motor':['0,176/255,80/255'],
'Marine':['84/255,141/255,212/255'],
'Commercial':['246/255,132/255,38/255'],
'Home Essentials':['1,128/255,1'],
}
var n = new Array();
for (var i in c) n.push(i);
var result = app.popUpMenu.apply(app,n);
if (result) {
this.fillColor = ["RGB",c[result]];
}
Copy link to clipboard
Copied
Thank you Thom, i was thinking of that change too.