Skip navigation
Currently Being Moderated

Hiding fields

Jul 25, 2012 2:02 PM

Hello,

 

I have some fields that are hidden or visible depending on the value chosen in 3 DDLs. I have the script on the Change event of the third DDL.

 

That works fine, (i.e., the correct fields are made visible) unless the user goes back and changes their selection in any field, then the fields don't become hidden again.

 

Here's my script:

 

var v1 = form1.page1.sectionOne.positioned2.division.rawValue;
var v2 = form1.page1.sectionOne.positioned2.AssocType.rawValue;
var v3 = form1.page1.positioned3.sectionTwo.windsNtwkAccess.rawValue

if ((v1 == '1') && (v3 == '1'))
{
form1.page4.eitEquipment.presence = "visible";
form1.page4.pcEquip.newReplace.presence = "hidden";
form1.page4.pcEquip.select.selEquip.presence = "hidden";
form1.page4.pcEquip.loaner.presence = "hidden";

} else {
if ((v1 == '1') && (v3 != '1'))
{
form1.page4.eitEquipment.presence = "hidden";
form1.page4.pcEquip.newReplace.presence = "hidden";
form1.page4.pcEquip.select.selEquip.presence = "hidden";
form1.page4.pcEquip.loaner.presence = "hidden";


} else {
if ((v1 == '1') && (v2 == '5'))
{
form1.page4.eitEquipment.presence = "hidden";
form1.page4.pcEquip.newReplace.presence = "hidden";
form1.page4.pcEquip.select.selEquip.presence = "hidden";
form1.page4.pcEquip.loaner.presence = "hidden";

} else {

if ((v1 == '2') && (v2 == '1') && (v3 == '1'))
{
form1.page4.eitEquipment.presence = "hidden";
form1.page4.pcEquip.newReplace.presence = "visible";
form1.page4.pcEquip.select.selEquip.presence = "visible";
form1.page4.pcEquip.loaner.presence = "hidden";

} else {
if ((v1 == '2') && (v2 != '1') && (v3 == '1'))
{
form1.page4.eitEquipment.presence = "hidden";
form1.page4.pcEquip.loaner.presence = "visible";
form1.page4.pcEquip.select.selEquip.presence = "visible";
form1.page4.pcEquip.newReplace.presence = "hidden";

} else {
if ((v1 == '2') && (v2 != '1') && (v3 != '1'))
{
form1.page4.eitEquipment.presence = "hidden";
form1.page4.pcEquip.loaner.presence = "hidden";
form1.page4.pcEquip.select.selEquip.presence = "hidden";
form1.page4.pcEquip.newReplace.presence = "hidden";

}}}}}}

 

Thanks for your help,

MDawn

 
Replies
  • Currently Being Moderated
    Jul 26, 2012 12:32 PM   in reply to mdawn50

    Hi,

     

    If it is a small form then you could use the layout:ready event of page4. Same script, just diffferent event. However the layout:ready event fires every time the user interacts with the form, so it can become a performance issue. See example here: http://assure.ly/nB0Bvz.

     

    You could move the script into a function (in a script object) and then call the function in the exit event of all three dropdowns. The example here show screenshots of script objects etc.: http://assure.ly/yDtfsM.

     

    Hope that helps,

     

    Niall

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 26, 2012 10:34 PM   in reply to mdawn50

    Possibly not Margaret.

     

    A typical if/else statement would look like this:

     

    if (a condition) {
         //Script
    }
    else if (another condition) {
         //Script
    }
    else if (another condition) {
         //Script
    }
    

     

    Try structuring the script like this.

     

    Niall

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 31, 2012 2:25 PM   in reply to mdawn50

    Hi Margaret,

     

    Sorry for the delay!

     

    Yes, you can include several conditions within the one if statement. Normally I would just include then without the additional brackets. For example:

     

    if (v1 == '1' && v3 == '1') {
         //Script
    }
    

     

    But I suspect that this is not the issue.

     

    Good luck,

     

    Niall

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 31, 2012 3:03 PM   in reply to mdawn50

    Hi Margaret,

     

    i can't check that issue now. However can you double check in LC Designer that the content is set to a presence of visible and that it is only the subform is set to hidden.

     

    Niall

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points