Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Hidden fields and deleted context

Avatar

Former Community Member

I've created a form with text fields that are hidden or visible depending upon selections made in two previous drop-down lists. The user of the form has different text fields to type into depending on their choice. The problem I'm having is that I only want to retain the contents of the visible field and only want the contents of the visible field to be saved in the XML of .csv. In other words--if they make another selection from the drop-down lists to "activate" different text fields--the text in the previously visible text fields would be deleted. I'm sure the logic has something to do with "if presence = hidden, then value = null" but I'm completely new to scripting in LiveCycle and have no idea how to write this.

I don't see a way to post a PDF, but I've inserted my code below.

----- form1.#subform[0].VariableLocation::exit: - (JavaScript, client) -----------------------------

//Clear out the StaticLocation DropDown list

StaticLocation.rawValue = "";

StaticLocation.clearItems();

switch (this.rawValue)

{

case "Top Center  ":

StaticLocation.addItem("Lower Right");

StaticLocation.addItem("None");

break;

case "Lower Right":

StaticLocation.addItem("Top Center  ");

StaticLocation.addItem("None");

break;

case "Top Center":

StaticLocation.addItem("Lower Left");

StaticLocation.addItem("None");

break;

case "Lower Left":

StaticLocation.addItem("Top Center");

StaticLocation.addItem("None");

break;

}

//TextFields 1a-4a

if (this.rawValue == "Top Center")

{

     TextField1a.presence = "visible";

}

else

{

     TextField1a.presence = "hidden";

}

if (this.rawValue == "Lower Left")

{

     TextField2a.presence = "visible";

}

else

{

     TextField2a.presence = "hidden";

}

if (this.rawValue == "Top Center  ")

{

     TextField3a.presence = "visible";

}

else

{

     TextField3a.presence = "hidden";

}

if (this.rawValue == "Lower Right")

{

     TextField4a.presence = "visible";

}

else

{

     TextField4a.presence = "hidden";

}

//TextFields 1b-4b

if (this.rawValue == "Top Center")

{

     TextField1b.presence = "visible";

}

else

{

     TextField1b.presence = "hidden";

}

if (this.rawValue == "Lower Left")

{

     TextField2b.presence = "visible";

}

else

{

     TextField2b.presence = "hidden";

}

if (this.rawValue == "Top Center  ")

{

     TextField3b.presence = "visible";

}

else

{

     TextField3b.presence = "hidden";

}

if (this.rawValue == "Lower Right")

{

     TextField4b.presence = "visible";

}

else

{

     TextField4b.presence = "hidden";

}

//TextFields 1c-4c

if (this.rawValue == "Top Center")

{

     TextField1c.presence = "visible";

}

else

{

     TextField1c.presence = "hidden";

}

if (this.rawValue == "Lower Left")

{

     TextField2c.presence = "visible";

}

else

{

     TextField2c.presence = "hidden";

}

if (this.rawValue == "Top Center  ")

{

     TextField3c.presence = "visible";

}

else

{

     TextField3c.presence = "hidden";

}

if (this.rawValue == "Lower Right")

{

     TextField4c.presence = "visible";

}

else

{

     TextField4c.presence = "hidden";

}

//TextFields 1d-4d

if (this.rawValue == "Top Center")

{

     TextField1d.presence = "visible";

}

else

{

     TextField1d.presence = "hidden";

}

if (this.rawValue == "Lower Left")

{

     TextField2d.presence = "visible";

}

else

{

     TextField2d.presence = "hidden";

}

if (this.rawValue == "Top Center  ")

{

     TextField3d.presence = "visible";

}

else

{

     TextField3d.presence = "hidden";

}

if (this.rawValue == "Lower Right")

{

     TextField4d.presence = "visible";

}

else

{

     TextField4d.presence = "hidden";

}

//TextFields 1e-4e

if (this.rawValue == "Top Center")

{

     TextField1e.presence = "visible";

}

else

{

     TextField1e.presence = "hidden";

}

if (this.rawValue == "Lower Left")

{

     TextField2e.presence = "visible";

}

else

{

     TextField2e.presence = "hidden";

}

if (this.rawValue == "Top Center  ")

{

     TextField3e.presence = "visible";

}

else

{

     TextField3e.presence = "hidden";

}

if (this.rawValue == "Lower Right")

{

     TextField4e.presence = "visible";

}

else

{

     TextField4e.presence = "hidden";

}

//TextFields 1f-4f

if (this.rawValue == "Top Center")

{

     TextField1f.presence = "visible";

}

else

{

     TextField1f.presence = "hidden";

}

if (this.rawValue == "Lower Left")

{

     TextField2f.presence = "visible";

}

else

{

     TextField2f.presence = "hidden";

}

if (this.rawValue == "Top Center  ")

{

     TextField3f.presence = "visible";

}

else

{

     TextField3f.presence = "hidden";

}

if (this.rawValue == "Lower Right")

{

     TextField4f.presence = "visible";

}

else

{

     TextField4f.presence = "hidden";

}

//TextFields 1g-4g

if (this.rawValue == "Top Center")

{

     TextField1g.presence = "visible";

}

else

{

     TextField1g.presence = "hidden";

}

if (this.rawValue == "Lower Left")

{

     TextField2g.presence = "visible";

}

else

{

     TextField2g.presence = "hidden";

}

if (this.rawValue == "Top Center  ")

{

     TextField3g.presence = "visible";

}

else

{

     TextField3g.presence = "hidden";

}

if (this.rawValue == "Lower Right")

{

     TextField4g.presence = "visible";

}

else

{

     TextField4g.presence = "hidden";

}

//TextFields 1h-4h

if (this.rawValue == "Top Center")

{

     TextField1h.presence = "visible";

}

else

{

     TextField1h.presence = "hidden";

}

if (this.rawValue == "Lower Left")

{

     TextField2h.presence = "visible";

}

else

{

     TextField2h.presence = "hidden";

}

if (this.rawValue == "Top Center  ")

{

     TextField3h.presence = "visible";

}

else

{

     TextField3h.presence = "hidden";

}

if (this.rawValue == "Lower Right")

{

     TextField4h.presence = "visible";

}

else

{

     TextField4h.presence = "hidden";

}

//TextFields 1i-4i

if (this.rawValue == "Top Center")

{

     TextField2i.presence = "visible";

}

else

{

     TextField2i.presence = "hidden";

}

if (this.rawValue == "Lower Left")

{

     TextField1i.presence = "visible";

}

else

{

     TextField1i.presence = "hidden";

}

if (this.rawValue == "Top Center  ")

{

     TextField4i.presence = "visible";

}

else

{

     TextField4i.presence = "hidden";

}

if (this.rawValue == "Lower Right")

{

     TextField3i.presence = "visible";

}

else

{

     TextField3i.presence = "hidden";

}

.

1 Accepted Solution

Avatar

Correct answer by
Former Community Member
4 Replies

Avatar

Former Community Member

In each of the lines where you set the presence to hidden, you can add a new line that will clear the field.

Something like this:

FieldName.rawValue = "";

Paul

Avatar

Former Community Member

Thanks for the pointer.

Would it look like this?

if (this.rawValue == "Top Center")
{
     TextField1a.presence = "visible";
}
else
{
     TextField1a.presence = "hidden";

     TextField1a.rawValue = "";  

}


Avatar

Correct answer by
Former Community Member

Yes

Avatar

Former Community Member

OK. I tried it and it worked beautifully.  Thank you very much!

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----