Hi,
I have two lists and I wanted to make sure that people select from the first drop down list before selecting from the second drop down list. So what I tried to do was, if the user tries to pick something from the second list and the first list was not selected, an error message will pop up to ask user to select from the first list.
The problem that I encountered: I cannot pass the value from the first list to the second list to check and see if the first list has got anything selected. Any idea?
First list: department
second list: jobs
in the first drop down list
var selected = xfa.event.newText;
second drop down list
if(selected==""||selected=="null"){
xfa.host.messageBox("Please select from the first drop down list before selecting from this list.");
}
Thanks,
F.
Solved! Go to Solution.
Views
Replies
Total Likes
Hi,
In the first dropdown script you declare a variable "selected". This form variable only lives within that event. You cannot accessthat variable from other events or from other objects.
You are on the right track, but instead of testing the variable in the if statement, test the rawValue of the first dropdown.
if (dropdown1.rawValue == null || dropdown1.rawValue == "")
{
xfa.host.messageBox(...);
xfa.host.setFocus("xfa.form.form1.page2.dropdown1");
}
Hope that helps,
Niall
Views
Replies
Total Likes
Hi,
In the first dropdown script you declare a variable "selected". This form variable only lives within that event. You cannot accessthat variable from other events or from other objects.
You are on the right track, but instead of testing the variable in the if statement, test the rawValue of the first dropdown.
if (dropdown1.rawValue == null || dropdown1.rawValue == "")
{
xfa.host.messageBox(...);
xfa.host.setFocus("xfa.form.form1.page2.dropdown1");
}
Hope that helps,
Niall
Views
Replies
Total Likes
Hi,
In the click event of the 2nd DropDown you can write the following script.
if (DropDownList1.rawValue == null)
{
xfa.host.messageBox("Please select from the first drop down list before selecting from this list.");
}
Generally null is not written within double quotes.
One more suggestion would be make the 2nd DropDown readOnly. In the Change event of the first dropDown make it not readOnly.
Thanks,
Bibhu.
Sorry Niall, Concurrent action again.
Bibhu.
Views
Replies
Total Likes
Hi Niall,
It worked! Thanks for pointing that out! I understand now. Presume that they are considered as local variables unless we set them to global.
Thanks heaps!
Regards,
Florian
Views
Replies
Total Likes
Hi Bibhu,
Thanks for your suggestion. That's a good idea too! I shall try that too and see if it works.
Regards,
Florian
Views
Replies
Total Likes
Hi Florian,
You could use global variables, but in this case you don't really need them.
When using global variables, you would declare them in File > Form Properties > Variables. To read or write variables in script you would use the .value: eg globalVariableName.value.
[No worries Bibhu ]
Niall
Views
Replies
Total Likes
Hi Niall,
OK, thanks again.
Regards,
F.
Views
Replies
Total Likes
Views
Likes
Replies