javascript - How do I remove a selected option dynamically -
I am trying to find out the junkie deletion of an option after selecting the user.
& lt; Select ID = "Field 4" name = "ProductCancingAutomom" style = "width: 30%" & gt; & Lt; Option value = "" & gt; -Please select - & lt; / Options & gt; & Lt; Option value = "1" & gt; 1 & lt; / Options & gt; & Lt; Option value = "2" & gt; 2 & lt; / Options & gt; & Lt; Option value = "3" & gt; 3 & lt; / Options & gt; & Lt; Option value = "4" & gt; 4 & lt; / Options & gt; & Lt; Option value = "5" & gt; 5 & lt; / Options & gt; & Lt; / Select & gt; & Lt; Select ID = "Field 5" name = "ProductCancingTworks" style = "width: 30%" & gt; & Lt; Option value = "" & gt; -Please select - & lt; / Options & gt; & Lt; Option value = "1" & gt; 1 & lt; / Options & gt; & Lt; Option value = "2" & gt; 2 & lt; / Options & gt; & Lt; Option value = "3" & gt; 3 & lt; / Options & gt; & Lt; Option value = "4" & gt; 4 & lt; / Options & gt; & Lt; Option value = "5" & gt; 5 & lt; / Options & gt; & Lt; / Select & gt; & Lt; Select ID = "Field 6" name = "ProductCancingEkker" style = "width: 30%" & gt; & Lt; Option value = "" & gt; -Please select - & lt; / Options & gt; & Lt; Option value = "1" & gt; 1 & lt; / Options & gt; & Lt; Option value = "2" & gt; 2 & lt; / Options & gt; & Lt; Option value = "3" & gt; 3 & lt; / Options & gt; & Lt; Option value = "4" & gt; 4 & lt; / Options & gt; & Lt; Option value = "5" & gt; 5 & lt; / Options & gt; & Lt; / Select & gt;
Therefore, after selecting "1" from "Field 4", "1" field will not appear in 5-etc.
I tried:
$ document.getElementById ("field4"). AddEventListener ("Change", function (select) {if (this.value! = "") {Var select2 = document.getElementById ("field5"); (Var i = 0; i
Use .remove ()
on options < / Code>
select2.remove (i); // i is the value index of the index that you want to delete
Comments
Post a Comment