javascript: how to make multiple combo boxes with same data - javascript

i have a scenario in JSP where i have to make a combo with a list containing 10 items say 1,2,3.... 10. now i select a combo. I also need to provide an add button that will add another combo with same elements except the one being selected in previous combo.
eg- if 1st combo selected value is 1 then in the next combo i'll have the list as 2,3,4.....10 i.e, having 9 elements and so on. the user can add 10 combos like this, each combo having the items that haven't been previously selected.
can anyone help me with this???
thanks in advance :) !!!

just to clear things out, your scenario is that you have 10 combo boxes that contain values from 1 to 10... i suggest you can use a case statement, or multiple if statements, you can use javascript for that...

Related

Remove entire table row having checkbox which was unchecked , when user click on submit button

I have table with checkall/uncheckall check box functionality and table is having and some input fields like text boxes, dropdowns. User should select at least one checkbox for processing the data in the table. That is working fine. For example table is having 3 rows and user select any one checkbox and click on submit button then remaining two table rows should be removed and not being submitted. I tried with the below one .
$("input:not(:checked)").each(function () {
$('input:not(:checked)').closest('tr').remove();
});
But this one is removing entire table. So I need only those table rows which are unchecked should be removed. Any help would be greatly appreaciated.
Assuming you don't use <th></th>, your header row also got selected because that checkbox is also unchecked. May be that will be the reason all rows got deleted. Console input:not:(:checked) it . It will give clear idea.
Edit:
Then try this, may be this will work
$('#tableid').find('tr[input:not:(:checked)]').each(function()
{
$(this).remove();
}
It seems to be working fine for me: https://jsfiddle.net/r9zgvbqu/7/
Two comments, you are using the .each() function to do something for all elements selected by "input:not:(:checked)", but in that function selecting everything again. so you are just doing the same thing multiple times. You can skip that step, and also skip the .each()-$(this) combination that has been suggested, by straightup doing:
$("input:not(:checked)").closest('tr').remove();
This removes all the you want.
EDIT: Your problem is that you are selecting all non-checked inputs, including text inputs etc. You can specify the type of input you are selection: input[type=checkbox]:not(:checked)
In general, I would avoid selecting elements by their tag name. It's better to give the relevant checkboxes a class, and you can select them by class.
Here is a fixed version of your fiddle: https://jsfiddle.net/927sdh8n/
And here is a simpler and safer version using classes: https://jsfiddle.net/qz53wfxc/

multiple select angular-materialize

I'm using angular-materialize to generate a multiple select :
http://krescruz.github.io/angular-materialize/
I'm using ng-model to retrieve the selected items, all this works, however I tried to add a search box in order to filter what I need.
my problem is I search for the first time and check the value, but then when I make an other search (that doesn't lead to the previously selected item) it is deleted and I'm only left with the last selected items.
So my questions are :
1/ is there a way to conserve all the selected items even with multiple search?
2/ is it possible to always have the dropdown "active" meaning I won't have to click in order to have the list ? (if that helps the previous problem)
Thank you

Data in multiple dropdowns

I have a form which contains 10 dropdown controls. Each control will be populated with the same 20 rows of data which are selected from a db table.
What I want to do is ensure that when the final choice is made there are no duplicates.
I could easily just do some error checking when I save the data, but maybe there is a slick way of hiding or graying out the items once they are chosen with javascript.
Has anyone done anything like this?
You could remove items from the other dropdowns when an item is selected in one. So other dropdowns want have that item for selection.

Validate that dropdown values are all distinct from one another with Javascript and/or Jquery?

I have a form with 7 dropdowns, all containing the values 1-7.
What is the easiest way to validate (using a function) that all of the "selected" values are distinct from one another using Javascript and/or Jquery?
Thanks in advance.
Create array that contains 1-7 values
In first dropdown add all these 7 values
On the "OnSelect" event of the first dropdown remove the selected value from array and add the array in 2nd dropdown.
This will add all the values in 2nd dropdown except the one selected in first dropdown
Continue for all the 7 dropdowns

Select Row or Column of checkboxes from matrix using javascript

As the title states I was wondering how i could perform the task of selecting a whole row/column of checkboxes using javascript as i have already done it with a foreach but that takes 3 seconds i wish that i can make this less.
1 2 3 4 5 select start end
1 Button
2
3
4
5
select
Im not sure how to depict it exactly i hope that this can better explain.
You could use css classes to designate the rows and columns for each checkbox, and then use jQuery to get the row or column of interest, like in this fiddle.
In the example, $('.r2') gets all checkboxes with the class 'r2' (ie., in row 2) ... change it to $('.c3') to get all in column 3.
Here is an example of creating a button to check a row or column.
UPDATE: Here is a more dynamic example
check out jQuery's .each function it would make that task piece of cake :)
Let me know if you need assistnace with it.

Categories