Expand my Community achievements bar.

Code not compiling as expected

Avatar

Level 2

Hi guys

I have some coding problem, can you please assist if possible.

Goal - if a certain field is selected in a drop down list, a hidden field will display below else stay hidden.

So far this code work -

if(Form.recipDetailsORG_pg.appDetailsORG_sf.Details_sf.DropDownList2.isNull)

{

     Form.recipDetailsORG_pg.appDetailsORG_sf.Details_sf.DropDownList3.presence = "hidden";

}

else if(Form.recipDetailsORG_pg.appDetailsORG_sf.Details_sf.DropDownList2.rawValue == "0")

{

     Form.recipDetailsORG_pg.appDetailsORG_sf.Details_sf.DropDownList3.presence = "hidden";

}

else if(Form.recipDetailsORG_pg.appDetailsORG_sf.Details_sf.DropDownList2.rawValue == "5")

{

     Form.recipDetailsORG_pg.appDetailsORG_sf.Details_sf.DropDownList3.presence = "hidden";

}

else if(Form.recipDetailsORG_pg.appDetailsORG_sf.Details_sf.DropDownList2.rawValue == "7")

{

     Form.recipDetailsORG_pg.appDetailsORG_sf.Details_sf.DropDownList3.presence = "hidden";

}

else if(Form.recipDetailsORG_pg.appDetailsORG_sf.Details_sf.DropDownList2.rawValue == "12")

{

     Form.recipDetailsORG_pg.appDetailsORG_sf.Details_sf.DropDownList3.presence = "hidden";

}

else if(Form.recipDetailsORG_pg.appDetailsORG_sf.Details_sf.DropDownList2.rawValue == "13")

{

     Form.recipDetailsORG_pg.appDetailsORG_sf.Details_sf.DropDownList3.presence = "hidden";

}

else

{

     Form.recipDetailsORG_pg.appDetailsORG_sf.Details_sf.DropDownList3.presence = "visible";

}

That's all very long is hard to read, so wrote up something smaller below, but for some reason it doesn't work. Does anybody know why? This code is under the 'Exit' event

var selectedRecip = Form.recipDetailsORG_pg.appDetailsORG_sf.Details_sf.DropDownList2.value;

if((selectedRecip == "") || (selectedRecip == "0") || (selectedRecip == "5") || (selectedRecip == "7") || (selectedRecip == "12") || (selectedRecip == "13"))

{

Form.recipDetailsORG_pg.appDetailsORG_sf.Details_sf.DropDownList3.presence = "hidden";

}

else

{

Form.recipDetailsORG_pg.appDetailsORG_sf.Details_sf.DropDownList3.presence = "visible";

}

Any help would be appreciated.

Thanks

Van

5 Replies

Avatar

Level 7

you seem to have a space in some of your words that might be causing the issue:

var selectedRecip = Form.recipDetailsORG_pg.appDetailsORG_sf.Details_sf.DropDownList2.val ue;

Form.recipDetailsORG_pg.appDetailsORG_sf.Details_sf.DropDownList3.pres ence = "hidden";

Form.recipDetailsORG_pg.appDetailsORG_sf.Details_sf.DropDownList3.pres ence = "visible";

Avatar

Level 2

I'm not sure why there's those spaces there, it mustn't of copied over properly. But there's none of those spaces there in my code.

Avatar

Level 10

At the end of this it should be rawValue not value.

Avatar

Level 2

Beautiful that work for the majority of it. Thanks Jono What still doesn't work is when the drop down list is null, the hidden field still appear when the drop down list have a null value. Do you know why this is happening?

Avatar

Level 10

Not sure, but in your if statement maybe try isNull instead of "" for your first test like you have in your first set of code above.