Disable Options in Dropdown Menu

In my app, each user selects one "player" per week and then is no longer able to use that same "player" again. I am looking for a way to disable the previously selected "player" from a dropdown menu, based off of the logged in user's previous selections. It seems that I need to add in a custom code in order to do this, but I really have no idea where to begin. Any help that can be offered, would be greatly appreciated.

We could do that - the only downside I see is that some browsers will allow you to disable those alerts. If your comfortable with that, I can make that change. (Well take all of 30 seconds).

Let me know.


Thank you for checking back and my apologies for the delayed response. The solution is great!! Thank you very much for the help. The only question I had is regarding the message "You have already selected this golfer". Is it at possible to have that in a pop up message when a user tries to press submit, vs. it just populating on the page?

No big deal, just looking out for those who fail to see the message (even though I changed it to bold letters and red font). Otherwise, it's great and again, thank you much for the help.


Just wondering if you had a chance to take a look, and make sure it is working to your specifications. Let me know if there is anything I need to change or update.


Alright you're all set -

Chris, you'll notice a Rich Text and Table on the scene that your form submission is on. The Rich Text is what will show to your user when they try to select an option they've already used. (Perhaps a place for a funny picture, but that may just be me) and the table will determine what options are not allowed for another selection. Reminder, if there are multiple pages of information in the table, it will only use page 1. (I set the default to 50 records, sounds like that should be plenty)

Below is the noted code for anyone interested

//Function to determine if the selected option has already been selected based off the table populating (see below)
function change_golfer () {
    //Finds index of current selection and gets the text of that selection
	var x = select_connect.selectedIndex
    sel_golfer = select_connect.options[x].text
//Loops thru golfers previously selected and checks if selection has been used in the past
for (j = 0; j < golfers.length; j++) {

//If match is found - displays the msg for the duplicate text and sets a boolean to true, ends loop
  if (sel_golfer == golfers[j]) {
    already_select = true
    dup_msg.style.visibility = "visible";
  //if Match is not found hides the duplicate text and set the boolean to false
  else {
    dup_msg.style.visibility = "hidden";
    already_select = false;



$(document).on(‘knack-scene-render.scene_72’, function() {

//Find field that the user will be selecting from
select_connect = document.getElementById(“view_172-field_179”);

//Find field that contains the message if the user selects a duplicate entry
dup_msg = document.getElementById(“view_177”)

//Hide the Duplicate message by default
dup_msg.style.visibility = “hidden”

//Call the functions to check the if the default selection has been used

//When the selection is change, call the check function
$(’#view_172-field_179’).on(‘change’, change_golfer)

//When the submit button is clicked, if the current selection is a duplicate, nothing is submitted
$("#view_172 .kn-submit input[type=submit]").on(“click”, function() {
if (already_select == true) {
return false;



//Gathers the data from past selections and puts into an array for use when checking
//Could have been done with an API call as well
//Using table allows user to change criteria thru the interface rather than changing an API call
$(document).on(‘knack-view-render.view_176’, function (event, view, data) {
golfers = ]
for (i = 0; i < data.length; i++) {
golfers[i] = data[i].field_179_raw[0].identifier;
//Remove the “//” from the lines below if you want to hide the table
//var data_table = document.getElementById("#view_176");
//data_table.style.visibility = “hidden”;

Yes sir, will do. Thanks again and please let me know if anything else is needed from my end.

It would be per User so we should be fine then.

I'll add the table and everything here tonight when I'm off work. If you could leave the data in there for now (gives us something to validate the code off of).


Sorry for the delayed response. The outside of the box solution sounds like it will work just fine! Would the "100 at a time" number be per user or for all users? If it's per user as he/she is logged in, we're fine. There will only be 24 selections per user, per year. I am planning on wiping out the 2015 data and starting fresh.

Please let me know if you need anything else from my end. Thank you very much for the help provided and working through this one with me.

Well I've never worked with the Connections drop down fields in this manner and its proving to be interesting.

It doesn't appear that the options are in the HTML unlike "Multiple Selection" field in the DB. Unforunately, that means we can't just remove the options at will. (It might be possible but its beyound my knowledge)

Out side the box solution - I can't think of a way to stop them from seeing a selection that the User has already used, however we could make it so that if they do select a Player that they've already used, that an alert on their browser (or a text field on the form, however you'd want to do it) would appear telling them "Sorry..." and the "Submit" button would be disabled and prevent them from continuing.

Since we need access to their past selections, the easiest way would be to put this in a table below the form. This stipulation is that it needs to show ALL of their past selections and Knack renders up to a 100 at a time (didn't dive into your data to see if that number was going to be a problem or not). You could tailor the table to show whatever selections you want (only last X months for the User, All for the User, etc) and when Knack loaded the page, it would use whatever data was going into that table as the deciding factor for above.

If this sounds like an acceptable solution to you - let me know. I can write the code for you (would need to create a login to the actual UI for myself so I can see the HTML on the render).

Ok thank for sharing.

I can think of two ways to do it.

1. Involves just Javascript, but I need to test that I can access the data easily (I won't do this in you're app but in one of my test apps).

It would involving adding something to your UI - but we'll see if work first.

2. API calls, this gets a little more complicated so hopefully option 1 works.

I will see what I can do and be in touch.

Got it

Just shared with you. Let me know if any direction is needed.

How to Share

email address you can share with is bennet.knack@gmail.com

Sorry for the delayed response. Yes, I am willing to share my app but also not quite sure how to go about that. If you can point me in the right direction, I am happy to share.

Having a hard time picturing how the DB is set up and how everything works together. Are you willing to share the app so I can take a look?

I pretty sure its possible but what it involves would depend on how its all set up.

**There are two separate objects within the same form that contain the values.

Thanks for getting back to me Bennet and my apologies for the original confusion. There are two separate objects. The first object is a calendar event, and there is one event each week for 27 weeks. The second object is a drop down menu of players (records) participating in the corresponding week's event. I have 60 users and each user selects a player (record) each week. My goal is to disable all of the players (records) from the current week's drop down menu that were previously selected based off the logged in user.

Hope this helps. Please let me know of any additional questions.


Could you clarify "Previous Selections"? - Are there multiple fields within the same form that contain the values? Or are they between different records.