I am working with Select form element having multiple dropdown choices as shown in the below screenshot. My requirement is, when I select a particular dropdown option & Save its details, I do not want the option to be available for further selection or disabling the Save button if the same option is selected, whichever is easy & convenient.
The other remaining dropdown choices which are not yet saved should be available for selection.
I am using Server Connect to post the selected details in the DB using insert API.
I see in your form’s success event you have a browser.goto… This obviously is an internal link.
So, in your success event, after that browser.goto step, set the save button disable to true
for example saveButton.disable(true)
I tried implementing the solution you suggested. However, it does not disable the Save button and I can still save the dropdown items multiple times after revisiting the page.
Is there something that I am missing?
<form id="frm_instAcadYear" is="dmx-serverconnect-form" method="post" action="/api/instProfile/acadYear/ins_acadYear" dmx-on:success="notifies1.success('Academic Year Selected');browser1.goto('/institute/institute-details',true,'Institute Details');btn_continue.disable(true)">
Thanks for the solution, it works. Howeever, it does not completely solve the issue i am trying to work.
The button is been diabled now, however, it remains disabled for the entire select element. I am not able to add another item from the dropdown which is not previously inserted/saved.
Is it possible to disable the button only for the already saved dropdown item & is enabled if I select another item from the dropdown which is not yet saved?
Alternatively, it is also fine if the already saved item can be removed from the dropdown list without having to disable the button.
I don’t have the full concept and code of your project so I can;t really know what is going on…
Can you share a small video of the actual problem on your browser and it would be helpfull to have the related code.
except the form with just a select and a save button…what happens?
You can try a few workarounds but it depends which one will work according to your setup…
First of all we agreed that this is a nodejs project, right?
And the frm_instAcadYear form is in a content page?
Each form contains anly one select?
How many forms you have?
Give me something more to be sure what we’re dealing with…
All we are trying to do is to “inform” your page that a select is saved so the relevent save button turns to disabled…
Yes, it is a nodejs project.
The content page has only one form with a select element which inserts the details of the selected year & redirects to the internal page.
As it is not possible to make video, I will explain the project using screenshots:
This is the page that I am working. It has select element, Save button, & repeat table (Active Profiles) to list the saved years.
The select element has 2 options
In the first image Active Years table, you can see AY 2023-24 saved. Now when I again click the select element & choosing AY 2023-24 from dropdown should disable the Save button.
If I select AY 2022-23 then the Save button should be enabled.
So, a fast answer is to check that on serverside…
When your select is updated, then check if the selected value exists and then disable the save button…(add a new serveraction that checks if the selected valuye of the select exists or no and fire it on your select change or updated event)
In a few words this is the workaround. If you need more help let me know
Another (better workaround) is to update the options in your select by checking if each option is already added in your table (“saved”) and if yes don’t include it in your select options. This way the select dropdown will always contain acceptable options only for the user to select
If you need help on this one tell me
Inside the serveraction that returns those options:
You have to filter your database query to include only values NOT IN these values:
A fast way is to create a query param type of array and every time you click the save , on success the option that was selected get added to that array.
Then inside your serveraction tht returns your table data (sc_qry_selectedAcadYear.data.query_selAcadYear) you add a GET parameter type of array (for example “usedVals”) and in your database query filter, you check that the values NOT IN the “usedVals”.
So every time the select is being loaded it will include only the options that has not been added to your table repeat
this returns the ids of the already used academic years in an Array
then in your existing query that returns the select options
sc_qry_masterAcadYear.data.query_masterAcadYear, you can filter it with the output of the previous step’s Array (usedAcadYearsID_Array): acadYearID NOT IN usedAcadYearsID_Array
(I don’t know if I write your fields and names correct , please check it)