store dropdown value to var on form load

DiveMasterTx

04-01-2019

I have several forms I'm trying to build and use dropdown fields in.  The forms work great up to a point, they store the user selected values when entered and saved, when reopened the form dropdown shows the saved value.  I am trying to use code to fire after the form opens and use the saved and visible dropdown value which loaded into the field via a function or with code.

I'm trying to read the saved value after it reopens and have tried unsuccessfully to use a lot of event.  I find it hard to believe the value is not  available

//doesn't retrieve any value if called from field events initialize, calculate, validate, postopen, docready, ready:form

var myrawValue = this.rawValue

var myValue = this.value

xfa.host.messageBox(myrawValue + " --> " +myValue ,"Show DropDown Values", 2, 2);

function fShowSign()
//Called from the field Change Event 

{

//called from the field change event works great!
//doesn't retrieve any value if called from field events initialize, calculate, validate, postopen, docready, ready:form

var oldValue = LP.Pg1.Pg1Ft.cboSigner.boundItem(xfa.event.prevText);  
var newValue = LP.Pg1.Pg1Ft.cboSigner.boundItem(xfa.event.newText);
  // For DEBUGGING purposes
xfa.host.messageBox(oldValue + " --> " +newValue ,"fShowSign", 2, 2);

// show the appropriate subform
switch (newValue) {
  case "2":
   xfa.resolveNode("LP.Pg1.Pg1Ft.sfrmSign1").presence= "visible";
   xfa.resolveNode("LP.Pg1.Pg1Ft.sfrmSign2").presence= "visible";
   xfa.resolveNode("LP.Pg1.Pg1Ft.sfrmSign3").presence= "hidden";
  break;
  default:
  // hide all
   xfa.resolveNode("LP.Pg1.Pg1Ft.sfrmSign1").presence= "hidden";
   xfa.resolveNode("LP.Pg1.Pg1Ft.sfrmSign2").presence= "hidden";
   xfa.resolveNode("LP.Pg1.Pg1Ft.sfrmSign3").presence= "hidden";
  break;
}
}

function fSignLoad()
{
//doesn't retrieve any value if called from field events initialize, calculate, validate, postopen, docready, ready:form
var myValue = LP.Pg1.Pg1Ft.cboSigner.boundItem(xfa.event.change); 
  // For DEBUGGING purposes
xfa.host.messageBox(myValue + " --> " +myValue ,"fSignLoad", 2, 2);
// show the appropriate subform
switch (myValue) {
  case "2":
   xfa.resolveNode("LP.Pg1.Pg1Ft.sfrmSign1").presence= "visible";
   xfa.resolveNode("LP.Pg1.Pg1Ft.sfrmSign2").presence= "visible";
   xfa.resolveNode("LP.Pg1.Pg1Ft.sfrmSign3").presence= "hidden";
  break;
  default:
  // hide all
   xfa.resolveNode("LP.Pg1.Pg1Ft.sfrmSign1").presence= "hidden";
   xfa.resolveNode("LP.Pg1.Pg1Ft.sfrmSign2").presence= "hidden";
   xfa.resolveNode("LP.Pg1.Pg1Ft.sfrmSign3").presence= "hidden";
  break;
}
}

View Entire Topic

MinusZero

06-01-2019

If you add a variable to your script object, you can recall and set it at any time by referencing it. You could set it when the dropdown is exited and recall it when the form is loaded in the docReady event.

1661718_pastedImage_0.png

In this example the reference would be vars.myVariable

Examples

vars.myVariable = TextField1.rawValue;

TextField1.rawValue = vars.myVariable;

Could this help you?