This is probably easier than I am making it out to be. However, I am having a hard time figuring it out.
I have 3 drop down lists that are titled Branch, Division, and Office. Each Branch is associated with only 1 Division and 1 Office. Thus, if someone selects a branch, the correct division and office should automatically be filled in for the Division and Office drop down lists.
Any quick and easy ideas how to accomplish this?
This is what I have, which doesn't work.
form1.Page1SubformFlowed.ReviewInfoSubform.Branch::change - (JavaScript, client)
if ($.boundItem(xfa.event.newText) == "ASDB" || "JFDB1" || "JFDB2" || "RRDB" || "PSDB") {
this.resolveNode("Division").rawValue = "DOD";
this.resolveNode("Office").rawValue = "CDRH/ODE";
}
else if ($.boundItem(xfa.event.newText) == "CDDB" || "CEDB" || "CSDB" || "ICDB" || "IEDB" || "PIDB" || "SHDB" || "VSDB") {
this.resolveNode("Division").rawValue = "DCD";
this.resolveNode("Office").rawValue = "CDRH/ODE";
}
Thanks!
Views
Replies
Total Likes
'$.boundItem(xfa.event.newText) ==' has to be placed after every conditional operator (||). So, if ($.boundItem(xfa.event.newText) == "ASDB" || $.boundItem(xfa.event.newText) =="JFDB1" || ....
Kyle
Views
Replies
Total Likes
Probably easier to use a switch statement. Also, not sure if the $ will work with JavaScript there.
(I think this is the correct syntax for multiple case options.)
switch(this.boundItem(xfa.event.newText) {
case "ASDB":
case "JFDB1":
case "JFDB2":
case "RRDB":
case "PSDB":
this.resolveNode("Division").rawValue = "DOD";
this.resolveNode("Office").rawValue = "CDRH/ODE";
break;
case "CDDB":
case "CEDB":
etc.
break;
}
Views
Replies
Total Likes
Apparently $ will work in JavaScript but I don't think it's officially supported. It's best not to use it in JavaScript if they do decide to completely deprecate it in later versions.
Here's another way using an object literal:
var myObj= {ASDB:{Division:"DOD",Office:"CDRH/ODE"},
JFDB1:{Division:"DOD",Office:"CDRH/ODE"},
JFDB2:{Division:"DOD",Office:"CDRH/ODE"},
RRDB:{Division:"DOD",Office:"CDRH/ODE"},
PSDB:{Division:"DOD",Office:"CDRH/ODE"},
CDDB:{Division:"DCD",Office:"CDRH/ODE"},
CEDB:{Division:"DCD",Office:"CDRH/ODE"},
CSDB:{Division:"DCD",Office:"CDRH/ODE"}};Division.rawValue=myObj[this.boundItem(xfa.event.newText)].Division;
Office.rawValue=myObj[this.boundItem(xfa.event.newText)].Office;
I always prefer working with arrays or objects when it comes to lists. That way if fields are changed/added/removed, the data (object literal in this case) remains the same and the only lines of code that need changing are the last two.
Kyle
Views
Replies
Total Likes
Neat bit of code Kyle, I'll have to play around with it. I'm not that advanced in JavaScript.
Views
Replies
Total Likes
And here you were teaching me JavaScript five years ago. Times have changed
Views
Replies
Total Likes
I was teaching myself at the same time!
Unfortunately, it's not the only thing I do around my work...but the only coding I do is in Designer.
Views
Replies
Total Likes
Views
Likes
Replies