Expand my Community achievements bar.

SOLVED

Don't allow to select duplicate entries from drop-down fields, JS pls.?

Avatar

Level 8

Hello

I have 3 drop down fields in my_sub_form, say, my_country_1, my_country_2 and my_country_3. All drop down field's list boxes are populated with 10 country names, say, US, Canada, Spain, Germany, France...

Say, user selected US in my_country_1 drop down field, again user is TRYING to select same entry as US in my_country_2 field======> Here at this point, as soon as user selected as US in my_country_2's droppped down list box=====> immediatley, I need to throw warning message to the user and make the my_country_2 as "" BLANK.

Basically, my form should not allow the user to select the DUPLICATE entries in these 3 drop-down fields, all the 3 should be DISTINCT.

If i write JS in EXIT event  of my_sub_form, its working fine, but not user friendly, it kind of late.

Hence we want to have INSTANT alert to user AS SOON AS user selects a duplicate entry in any drop down field

I tried to put some JS in CHANGE event of my_country_1 and my_country_2, but not working

Pls. provide me some JS and the event name, object name

Thank you

1 Accepted Solution

Avatar

Correct answer by
Level 7

you could put in the exit event of the my_country_1 list:

if (this.rawValue == my_country_2.rawValue || this.rawValue == my_country_3.rawValue)

{

xfa.host.messageBox("You cannot choose the same country");

this.rawValue = ""

}

and then put the same in the other dropdowns but change the names.

View solution in original post

1 Reply

Avatar

Correct answer by
Level 7

you could put in the exit event of the my_country_1 list:

if (this.rawValue == my_country_2.rawValue || this.rawValue == my_country_3.rawValue)

{

xfa.host.messageBox("You cannot choose the same country");

this.rawValue = ""

}

and then put the same in the other dropdowns but change the names.