Add/Remove or Show/Hide drop down list items - javascript

Basically I have 3 drop down lists for security questions. I have java script setup that will spring an alert when the box is changed. I need to know how to add/remove or show/hide an option. like if the first box selected option 1....remove option one from the other 2 drop downs as possible selections.

$('selector').append($('select options:gt(n)').detach());

Related

How to create multiple select drop-down check-box in Google Sheets/Apps Script?

I am trying to make a drop-down list in Google sheets, but the problem is I want multiple select feature in that dropdown. The checkbox feature available in Google sheet is only single select. I've searched a lot but all the available solutions consist creating a extra menu, but I want it to be multiple select checkbox in a dropdown.
This is not currently possible. You would have to write an add-on/sidebar that would let users select item(s) and then save values to the cell.

Is there a way to preload selected options on multiple chosen.js select boxes?

I have 10 forms with 5 chosen.js select boxes in each form group. When the page loads I want to load the chosen select boxes with options which have set on another select box, which is hidden from view.
The idea is that the user can deselect the options they don't want, and update the form.
There's a challenge in assigning the correct options to the correct chosen select but what I'm trying to do now is get the already selected options to show.
An example of what it would look like is near the top of the Chosen page. It appears when the page loads 'Sloth Bear' and 'Polar Bear' are already pre-populating their select box.
I've tried chosen:update but my understanding is that it only updates the possible options you can select, not what I'm wanting. I've also tried manually inserting a DOM node into the chosen input, but that wasn't working either.
So is what I'm trying possible? Or is it just an example on the website?

Dynamic rows in C# asp.net mvc

I am working in a c# project using MVC framework and Razor for the front view.
I am developing a form with dynamic grid which works based on the option selected from the dropdown list. On selecting the option I will generate a dynamic row containing either textbox or checkbox. When the user clicks Add new button
I have to show another dropdown list with options. Again based on the option selected another dynamic grid is once again added in the form just below the above steps. So it will be in a situation with row of textboxes and another row with checkboxes. The user can also delete the rows.
To accomplish this, I have tried the following approach in Javascript:
I used two tables in that
one table will dynamically apend by the dropdown when the user selects a row from the list.
In another table has the values of number of textboxes or checkboxes will be appended accordingly based on the
dropdown value is selected.
In this approach it continously adds a new row on clicking add new button. But when the dropdown option in row1 is changed then the corresponding checkbox must be replaced with text boxes and vice versa.
And consider I have a row with textboxes and another row with checkboxes. When a checkbox in row2 is checked then the corresponding text box in row1 must be disabled.
In this above approach I have to fix the issues in the 1. and 2. steps.
Please let me know is there any better approach other than javascript to implement this logic in C# MVC Razor framework.
Please kindly suggest me the best approach for dynamic grid and also whether javascript is fine to pass the variables to the controller. Thanks in advance.

Load options into select box when opened

I have a web page with many select boxes, which should each contain the same set of options. The idea is that the user is given a list of items and has to select the matching option for each from another list.
Since the lists are both several hundred items long, loading all the options into each selection box is slow. Also, most of the items are automatically matched to an option to begin with, and the user only needs to skim through and make sure they are correct, so most of the select boxes will never be opened.
What I ideally want is a method of populating the options for each select box only when it is opened. This would mean I could populate the options for the few items which are not matched automatically using onload and only populate the rest as they are needed.
Is it possible to add options to the select boxes as they are opened?
You can try and start with empty selects add the options using the onfocus event and if the select has 0 options add them.
Here is a example

Drop down box in form with a button to add a second copy of drop down box

I have a simple form that lists user names and for each user, the form displays a drop down box with a list of items that can be assigned to the user. Since it is often necessary to assign multiple items to a user, I need to display a button next to the drop down that says "add another item" which automatically inserts another an identical drop down box below the first one and preserves the selected option in the original drop down box.
You might be thinking - why not just display a series of radio buttons or checkboxes? Can't do that for two reasons, 1) the list of items is too long and 2) there are times when I need to assign the same item to a user twice.
I know this "add another item" button can be done in Javascript, I just don't know the code.
Here's an example of what I need to do (not working because there is no onClick function yet).
http://www.dropthechalk.org/sampleform.html
This has nothing to do with dynamically populating the items in the drop down box, so I've found it hard to search for solutions. Any help or links to resources much appreciated!
Here is a tutorial that I did a while ago on dynamically adding input elements via JavaScript. This should be a good starting point.

Categories

Resources