javascript - Detaching/appending select options with jquery -


I am trying to set up a form with several dropdown lists, allowing visitors to rank list items Will go. Sample Form:

  & lt; Form action = "" name = "ranks" & gt; & Lt; Select name = "rank1" id = "rank1" & gt; & Lt; Option value = "option1" & gt; Option 1 & lt; / Options & gt; & Lt; Option value = "option 2" & gt; Option 2 & lt; / Options & gt; & Lt; Option value = "option3" & gt; Option 3 & lt; / Options & gt; & Lt; Option value = "option4" & gt; Option 4 & lt; / Options & gt; & Lt; Option value = "option5" & gt; Option 5 & lt; / Options & gt; & Lt; / Select & gt; & Lt; Choose name = "rank 2" id = "rank 2" & gt; & Lt; Option value = "option1" & gt; Option 1 & lt; / Options & gt; & Lt; Option value = "option 2" & gt; Option 2 & lt; / Options & gt; & Lt; Option value = "option3" & gt; Option 3 & lt; / Options & gt; & Lt; Option value = "option4" & gt; Option 4 & lt; / Options & gt; & Lt; Option value = "option5" & gt; Option 5 & lt; / Options & gt; & Lt; / Select & gt; & Lt; Select name = "rank 3" id = "rank 3" & gt; & Lt; Option value = "option1" & gt; Option 1 & lt; / Options & gt; & Lt; Option value = "option 2" & gt; Option 2 & lt; / Options & gt; & Lt; Option value = "option3" & gt; Option 3 & lt; / Options & gt; & Lt; Option value = "option4" & gt; Option 4 & lt; / Options & gt; & Lt; Option value = "option5" & gt; Option 5 & lt; / Options & gt; & Lt; / Select & gt; & Lt; / Form & gt;  

is selected as the option, I want to separate them from each dropdown.

I have a lot of options in the actual list so that people can rank the top 10 out of 32 options, imagine the sample code with up to 10 dropdowns with 32 options each.

If someone chooses 'Option2' from the #Rank 1, then I want to remove Option 2 from this dropdown, and so on. If they go back to selecting #Rank 1, and change their option to 'Option 4', then 'Option 2' will be added to all the dropdowns.

I have taken a look at .detach () .append () but I do not really know what I am doing.

  $ ("option [value =" + $ (this) .val () + "]"). ();  

I tried to start up but it only removes the option from all the dropdowns. I am a JS / JPYour noob, so any help or link in the right direction is appreciated. is. Thanks!

Did you consider enabling / deactivating virtual acting and isolation?

I'm not quick with code (working with a broken arm here), but the usual algorithm would be:

  $ (function () {// Answer any value change $ ('Select'). Change (function () {var val = $ (this) .val (); // Enable / Disable based on selection. // View the answer to you After each loop removed (+1), they have a better solution. $ ('Select: No (#' + $ (this) .Parent () .ID + ') option [value =' + val + '] '). RemoveAttr (' disabled '); $ (' '(' 'disabled' ',' axis ('.');})}} ('' Select '$' $ (this) .Parent (.) Id + ') option [value =' + val + ']').  
< P> This test has not been done and I am still learning a lot of jQuery (so I will take feedback).


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -