why does the following code or elements.[theButton].fgcolor not work?
How can I pass the variable value into the elements.object.fgcolor?
Also, why would this method not continue at the switch statement where if I used var theForm = controller.getName(); does work?
var theButton = application.getMethodTriggerElementName();
//Reset all the buttons to black
elements.functionsButton.fgcolor = "#000000";
elements.codeButton.fgcolor = "#000000";
elements.techButton.fgcolor = "#000000";
elements.theButton.fgcolor = "#9C9779";
switch( theButton )
{
case "functionsButton":
forms.functions_list.showMe();
break;
case "codeButton":
forms.code.showMe();
break;
default:
break;
}
The intention is to make a universal navigation method tied to the navigational form with all of the buttons on it. Secondary goal is to change the text of the button clicked to indicate that is where the user is.
var theButton = application.getMethodTriggerElementName();
//Reset all the buttons to black
forms.myController.elements.functionsButton.fgcolor = "#000000";
forms.myController.elements.codeButton.fgcolor = "#000000";
forms.myController.elements.techButton.fgcolor = "#000000";
forms.myController.elements[theButton].fgcolor = "#9C9779";
switch( theButton )
{
case "functionsButton":
forms.functions_list.controller.show();
break;
case "codeButton":
forms.code.controller.show();
break;
default:
break;
}
Maarten, you can see that my code was within the controller that called the method so adding forms.myController wasn’t vital. Knowing that I didn’t need a period between elements.[theButton] was vital.
But my method still stops at the switch statement. It just kicks out. I don’t know why. I’m guessing the expression is not evaluating properly. I’m assuming because you modified the code you tried this out on a solution. Does your switch statement work?
ah right, I see what you mean.(script isn’t a global method)
the switch statement looks perfectly normal.(very strange)
I actually copy pasted your switch into my method
and it’s working fine.
-Can you check if your variable “theButton” get’s
a value , When running in debug mode?
Does your switch work when you replace the variable with a literal string “codeButton”?
-does the switch part work, when you leave out all the element fgcolor lines?
maarten:
ah right, I see what you mean.(script isn’t a global method)
the switch statement looks perfectly normal.(very strange)
I actually copy pasted your switch into my method
and it’s working fine.
-Can you check if your variable “theButton” get’s
a value , When running in debug mode?
Does your switch work when you replace the variable with a literal string “codeButton”?
-does the switch part work, when you leave out all the element fgcolor lines?
Using a literal does enter the switch but it kicks out and does not move to the form. I’ll send you the db and app via email. You can test there.
theButton variable does get a value. When you get the db and solution then check out the method named masterNav in the myController form.
nothing happens (it doesn’t run into the switch). the value returned in the example is 6. When I set art_auslieferung = 6 directly, everything is fine.
can i see the complete switch? And when it is going ok (if you set it hard to 6?)
Are the switch values integers?
please try to make art_auslieferung an integer first:
var art_auslieferung = parseInt(dataset.getValue(1, 5));
Ok, this is an open challenge to anyone who can make this method work.
Create two buttons on a form used as the controller for other forms. Name button one “Button_1” and name button two “Button_2”.
Create one global method and use the following code.
theButton = application.getMethodTriggerElementName();
//Reset all the buttons to black
forms.myController.elements.namedButton1.fgcolor = "#000000";
forms.myController.elements.namedButton2.fgcolor = "#000000";
//Dim the button clicked
forms.myController.elements[theButton].fgcolor = "#9C9779";
switch(theButton)
{
case "Button_1":
forms.some_form.controller.show();
break;
case "Button_2":
forms.a_different_form.controller.show();
break;
default:
break;
}
Assign the method to the two buttons.
Tell me this method code won’t work for you either and the switch statement will not execute. I’ve tried enough variations both as a local method and a global method. Neither have worked for me and the switch simply will not execute.
faheemhameed:
When I added your code to the following then it worked.
theButton = theButton + ‘’;
var theButton = application.getMethodTriggerElementName();
theButton = theButton + ‘’;
//Reset all the buttons to black
elements.functionsButton.fgcolor = “#000000”;
elements.codeButton.fgcolor = “#000000”;
elements.techButton.fgcolor = “#000000”;
elements.theButton.fgcolor = “#9C9779”;
switch( theButton )
{
case “functionsButton”:
forms.functions_list.showMe();
break;
case “codeButton”:
forms.code.showMe();
break;
default:
break;
}
Dang, this works. Never would have tried it myself.