When selections are made from a listbox (TACList), the listbox is hidden and another field (TACResults) displayed with the listbox values loaded into them. However if no selections are made, I want the user to be asked if that's what they really want.
1. If so, then, the listbox stays open, the results box stays hidden and the focus is set to a freeform description field.
2. If not, I want the focus back on the listbox so they can make selection(s).
I have been successful in doing all of this, but not all at once. If I apply only the second part of the script (ie. when selections are made), that part works perfectly.
If I apply the first part of the script independently, it works too.
But when I try to lump the tasks together, it fails.
I have the following script:
----- form1.TACPg1.TACSF.IndSF.TACList::exit: - (JavaScript, client) -------------------------------
if(this.rawValue == 0) //if no selection made
{
var noSelect = xfa.host.messageBox("Are you sure you don't want to make any selections?","No selections",2,2); //are you sure? - yes or no
if(noSelect == 4); //if yes
xfa.host.setFocus(IndSF.TACDtls); //set focus to the details field (& don't display the results box)
}
else
{
if(noSelect) == 3); //if no
xfa.host.setFocus(IndSF.FakeDDnFldSF.BlankBtn); //set the focus to the button
}
else
{
if(this.rawValue > 0); //otherwise if something is selected,
{
TACResults.presence = "visible"; //show the results
TACResults.rawValue = this.rawValue; //load the results of the list
TACDtls.presence = "visible"; //show the details field
xfa.host.setFocus(TACDtls); //set the focus to the details field
this.presence = "hidden"; //hide the dropdown list
xfa.host.resetData("xfa.form.form1.TACPg1.TACSF.IndSF.TACList"); //reset the dropdown list
}
I obviously have some syntax or structure wrong. Can anyone assist please?
if (condition a) {
do action 1
} else {
if (condition b) {
do action 2
} else {
... etc.
}
}Maybe this will help. I always find it confusing as to where to put the brackets and getting the right number of closing brackets. I think this may be your problem also. But I am rather new to Javascript myself so I could be wrong.
So based on the example, you might try it this way:
if(this.rawValue == 0) //if no selection made
{
var noSelect = xfa.host.messageBox("Are you sure you don't want to make any selections?","No selections",2,2); //are you sure? - yes or no
if(noSelect == 4); //if yes
{xfa.host.setFocus(IndSF.TACDtls); //set focus to the details field (& don't display the results box)
}
if(noSelect) == 3); //if no
{xfa.host.setFocus(IndSF.FakeDDnFldSF.BlankBtn); //set the focus to the button
}
}
else
{
TACResults.presence = "visible"; //show the results
TACResults.rawValue = this.rawValue; //load the results of the list
TACDtls.presence = "visible"; //show the details field
xfa.host.setFocus(TACDtls); //set the focus to the details field
this.presence = "hidden"; //hide the dropdown list
xfa.host.resetData("xfa.form.form1.TACPg1.TACSF.IndSF.TACList"); //reset the dropdown list
}