Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events
SOLVED

IF else If code not working

Avatar

Former Community Member

Hi guys,

basically, i'm trying to get an "if" exit event to read it's own events raw value, and another events rawvalue and then set field values based on that combo of values.

The long winded explanation -

i have two users, A and B, say.

user A fills in their details, then is given a dropdownlist with three options (values yes,no,help)

a switch statement is attached to the exit event of the dropdownlist.

if user A selects yes (option 1) their details are  then used as the rawvalues for jobvacancy1 (say).

if they select no (option 2) the rawvalues for jobvacancy1 (say) are set to "" -empty

if they select help (3) they get messagebox help - thats fine.

User B then fills in their details and has the same choices, provided by a different dropdown list.

if user A selected no, and user B selected yes - then user B's rawvalue details should fill jobvacancy1.

However if user A selected yes (option 1) and user B selected yes, then user B's details should fill jobvacancy2.

so, just a way of making sure if only one says yes, then user B is not in slot 2, with slot one unfilled. simple enough idea....

The switch statement I have on user A's question seems to works, and is here:

switch (this.rawValue) {

case "1":

page13.tee1sub.tee1firstname.rawValue = page6.onesettloronlypt1.onesetfname.rawValue;

page13.tee1sub.tee1midnames.rawValue = page6.onesettloronlypt1.onesetmidnames.rawValue;

page13.tee1sub.tee1famname.rawValue = page6.onesettloronlypt1.onesetsurname.rawValue;

page13.tee1sub.tee1occu.rawValue = page6.onesettloronlypt1.onesetjob.rawValue;

page13.tee1sub.tee1propno.rawValue = onesetpropno.rawValue;

page13.tee1sub.tee1streetname.rawValue = onesetstreet.rawValue;

page13.tee1sub.tee1town.rawValue = onesettown.rawValue;

page13.tee1sub.tee1postcode.rawValue = onesetpostcode.rawValue;

break;

case "2":

page13.tee1sub.tee1firstname.rawValue = "";

page13.tee1sub.tee1midnames.rawValue = "";

page13.tee1sub.tee1famname.rawValue = "";

page13.tee1sub.tee1occu.rawValue = "";

page13.tee1sub.tee1propno.rawValue = "";

page13.tee1sub.tee1streetname.rawValue = "";

page13.tee1sub.tee1town.rawValue = "";

page13.tee1sub.tee1postcode.rawValue = "";

break;

case "3":

xfa.host.messageBox ("once finished this will produce some help -for now however you will have to be content yourself with this loverly bing sound");

break;

}

The if statement i have on the exit event of the second user, seems to be broken - it works to set both vacancies, but does not work when user A says no, and user B says yes.

here's what i have:

if (page9.twosetts1p2.makesett1of2atee.rawValue == "1" && this.rawValue == "1")

{

page14.tee2sub.tee2firstname.rawValue = page10.twosetts1pt1.sett2of2fnmae.rawValue ;

page14.tee2sub.tee2midnames.rawValue = page10.twosetts1pt1.sett2of2midnames.rawValue;

page14.tee2sub.tee2famname.rawValue = page10.twosetts1pt1.sett2of2lastname.rawValue;

page14.tee2sub.tee2propno.rawValue = sett2of2propno.rawValue;

page14.tee2sub.tee2streetname.rawValue = sett2of2streetname.rawValue;

page14.tee2sub.tee2town.rawValue = sett2of2town.rawValue;

page14.tee2sub.tee2postcode.rawValue = sett2of2postcode.rawValue;

page14.tee2sub.tee2occu.rawValue = page10.twosetts1pt1.sett2of2job.rawValue;

}else if(page9.twosetts1p2.makesett1of2atee.value == "2" && this.value == "1"){

page13.tee1sub.tee1firstname.rawValue = page10.twosetts1pt1.sett2of2fnmae.rawValue ;

page13.tee1sub.tee1midnames.rawValue = page10.twosetts1pt1.sett2of2midnames.rawValue;

page13.tee1sub.tee1famname.rawValue = page10.twosetts1pt1.sett2of2lastname.rawValue;

page13.tee1sub.tee1propno.rawValue = sett2of2propno.rawValue;

page13.tee1sub.tee1streetname.rawValue = sett2of2streetname.rawValue;

page13.tee1sub.tee1town.rawValue = sett2of2town.rawValue;

page13.tee1sub.tee1postcode.rawValue = sett2of2postcode.rawValue;

page13.tee1sub.tee1occu.rawValue = page10.twosetts1pt1.sett2of2job.rawValue;

}else if (this.rawValue == "2") {

page14.tee2sub.tee2firstname.rawValue = "";

page14.tee2sub.tee2midnames.rawValue = "';

page14.tee2sub.tee2famname.rawValue = "";

page14.tee2sub.tee2propno.rawValue = "';

page14.tee2sub.tee2streetname.rawValue = "';

page14.tee2sub.tee2town.rawValue = "";

page14.tee2sub.tee2postcode.rawValue = "';

page14.tee2sub.tee2occu.rawValue = "";

}

any pointers would be much appreciated

1 Accepted Solution

Avatar

Correct answer by
Level 10

Simple typo mistake. You used value property instead of rawValue on the first else if part.

The error line is marked in RED color.

Nith

if (page9.twosetts1p2.makesett1of2atee.rawValue == "1" && this.rawValue == "1")

{

page14.tee2sub.tee2firstname.rawValue = page10.twosetts1pt1.sett2of2fnmae.rawValue ;

page14.tee2sub.tee2midnames.rawValue = page10.twosetts1pt1.sett2of2midnames.rawValue;

page14.tee2sub.tee2famname.rawValue = page10.twosetts1pt1.sett2of2lastname.rawValue;

page14.tee2sub.tee2propno.rawValue = sett2of2propno.rawValue;

page14.tee2sub.tee2streetname.rawValue = sett2of2streetname.rawValue;

page14.tee2sub.tee2town.rawValue = sett2of2town.rawValue;

page14.tee2sub.tee2postcode.rawValue = sett2of2postcode.rawValue;

page14.tee2sub.tee2occu.rawValue = page10.twosetts1pt1.sett2of2job.rawValue;

}else if(page9.twosetts1p2.makesett1of2atee.value == "2" && this.value == "1"){

page13.tee1sub.tee1firstname.rawValue = page10.twosetts1pt1.sett2of2fnmae.rawValue ;

page13.tee1sub.tee1midnames.rawValue = page10.twosetts1pt1.sett2of2midnames.rawValue;

page13.tee1sub.tee1famname.rawValue = page10.twosetts1pt1.sett2of2lastname.rawValue;

page13.tee1sub.tee1propno.rawValue = sett2of2propno.rawValue;

page13.tee1sub.tee1streetname.rawValue = sett2of2streetname.rawValue;

page13.tee1sub.tee1town.rawValue = sett2of2town.rawValue;

page13.tee1sub.tee1postcode.rawValue = sett2of2postcode.rawValue;

page13.tee1sub.tee1occu.rawValue = page10.twosetts1pt1.sett2of2job.rawValue;

}else if (this.rawValue == "2") {

page14.tee2sub.tee2firstname.rawValue = "";

page14.tee2sub.tee2midnames.rawValue = "';

page14.tee2sub.tee2famname.rawValue = "";

page14.tee2sub.tee2propno.rawValue = "';

page14.tee2sub.tee2streetname.rawValue = "';

page14.tee2sub.tee2town.rawValue = "";

page14.tee2sub.tee2postcode.rawValue = "';

page14.tee2sub.tee2occu.rawValue = "";

}

View solution in original post

2 Replies

Avatar

Correct answer by
Level 10

Simple typo mistake. You used value property instead of rawValue on the first else if part.

The error line is marked in RED color.

Nith

if (page9.twosetts1p2.makesett1of2atee.rawValue == "1" && this.rawValue == "1")

{

page14.tee2sub.tee2firstname.rawValue = page10.twosetts1pt1.sett2of2fnmae.rawValue ;

page14.tee2sub.tee2midnames.rawValue = page10.twosetts1pt1.sett2of2midnames.rawValue;

page14.tee2sub.tee2famname.rawValue = page10.twosetts1pt1.sett2of2lastname.rawValue;

page14.tee2sub.tee2propno.rawValue = sett2of2propno.rawValue;

page14.tee2sub.tee2streetname.rawValue = sett2of2streetname.rawValue;

page14.tee2sub.tee2town.rawValue = sett2of2town.rawValue;

page14.tee2sub.tee2postcode.rawValue = sett2of2postcode.rawValue;

page14.tee2sub.tee2occu.rawValue = page10.twosetts1pt1.sett2of2job.rawValue;

}else if(page9.twosetts1p2.makesett1of2atee.value == "2" && this.value == "1"){

page13.tee1sub.tee1firstname.rawValue = page10.twosetts1pt1.sett2of2fnmae.rawValue ;

page13.tee1sub.tee1midnames.rawValue = page10.twosetts1pt1.sett2of2midnames.rawValue;

page13.tee1sub.tee1famname.rawValue = page10.twosetts1pt1.sett2of2lastname.rawValue;

page13.tee1sub.tee1propno.rawValue = sett2of2propno.rawValue;

page13.tee1sub.tee1streetname.rawValue = sett2of2streetname.rawValue;

page13.tee1sub.tee1town.rawValue = sett2of2town.rawValue;

page13.tee1sub.tee1postcode.rawValue = sett2of2postcode.rawValue;

page13.tee1sub.tee1occu.rawValue = page10.twosetts1pt1.sett2of2job.rawValue;

}else if (this.rawValue == "2") {

page14.tee2sub.tee2firstname.rawValue = "";

page14.tee2sub.tee2midnames.rawValue = "';

page14.tee2sub.tee2famname.rawValue = "";

page14.tee2sub.tee2propno.rawValue = "';

page14.tee2sub.tee2streetname.rawValue = "';

page14.tee2sub.tee2town.rawValue = "";

page14.tee2sub.tee2postcode.rawValue = "';

page14.tee2sub.tee2occu.rawValue = "";

}

Avatar

Former Community Member

thanks Nith - i knew i had it (about ) right but......