How can I change select options with javascript?











up vote
-1
down vote

favorite












I have a select with options I need when I select an option another two disappear in the same select



<select class="select cf-select" name="customfield_10303" id="customfield_10303">
<option value="">None</option>
<option value="10200">Opened</option>
<option value="10201">Closed</option>
<option value="10202">Escalated</option>
<option value="10203">Handled</option>
<option value="10204">Deferred</option>
<option value="10205">Reopened</option>
<option value="10206">Could Not Be Resolved</option>
</select>


this is the HTML code I need javascript code when I select opened Just Escalated and Deferred are only appear










share|improve this question




















  • 2




    You forgot posting the code.
    – Foo
    Nov 11 at 13:58










  • All you have posted is a goal, but not any code related problems associated with achieving that goal as outlined in How to Ask and Minimal, Complete, and Verifiable example
    – charlietfl
    Nov 11 at 14:00












  • I select Opened Just Escalated and Deferred are only appear Ok. Why exactly these? According to what scheme?
    – Smollet777
    Nov 11 at 14:33










  • I have my own scheme I need to know how the code will look like I need this to add in Jira custom field issues
    – m.nabil
    Nov 11 at 14:39















up vote
-1
down vote

favorite












I have a select with options I need when I select an option another two disappear in the same select



<select class="select cf-select" name="customfield_10303" id="customfield_10303">
<option value="">None</option>
<option value="10200">Opened</option>
<option value="10201">Closed</option>
<option value="10202">Escalated</option>
<option value="10203">Handled</option>
<option value="10204">Deferred</option>
<option value="10205">Reopened</option>
<option value="10206">Could Not Be Resolved</option>
</select>


this is the HTML code I need javascript code when I select opened Just Escalated and Deferred are only appear










share|improve this question




















  • 2




    You forgot posting the code.
    – Foo
    Nov 11 at 13:58










  • All you have posted is a goal, but not any code related problems associated with achieving that goal as outlined in How to Ask and Minimal, Complete, and Verifiable example
    – charlietfl
    Nov 11 at 14:00












  • I select Opened Just Escalated and Deferred are only appear Ok. Why exactly these? According to what scheme?
    – Smollet777
    Nov 11 at 14:33










  • I have my own scheme I need to know how the code will look like I need this to add in Jira custom field issues
    – m.nabil
    Nov 11 at 14:39













up vote
-1
down vote

favorite









up vote
-1
down vote

favorite











I have a select with options I need when I select an option another two disappear in the same select



<select class="select cf-select" name="customfield_10303" id="customfield_10303">
<option value="">None</option>
<option value="10200">Opened</option>
<option value="10201">Closed</option>
<option value="10202">Escalated</option>
<option value="10203">Handled</option>
<option value="10204">Deferred</option>
<option value="10205">Reopened</option>
<option value="10206">Could Not Be Resolved</option>
</select>


this is the HTML code I need javascript code when I select opened Just Escalated and Deferred are only appear










share|improve this question















I have a select with options I need when I select an option another two disappear in the same select



<select class="select cf-select" name="customfield_10303" id="customfield_10303">
<option value="">None</option>
<option value="10200">Opened</option>
<option value="10201">Closed</option>
<option value="10202">Escalated</option>
<option value="10203">Handled</option>
<option value="10204">Deferred</option>
<option value="10205">Reopened</option>
<option value="10206">Could Not Be Resolved</option>
</select>


this is the HTML code I need javascript code when I select opened Just Escalated and Deferred are only appear







javascript html select jira






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 11 at 14:27

























asked Nov 11 at 13:56









m.nabil

86




86








  • 2




    You forgot posting the code.
    – Foo
    Nov 11 at 13:58










  • All you have posted is a goal, but not any code related problems associated with achieving that goal as outlined in How to Ask and Minimal, Complete, and Verifiable example
    – charlietfl
    Nov 11 at 14:00












  • I select Opened Just Escalated and Deferred are only appear Ok. Why exactly these? According to what scheme?
    – Smollet777
    Nov 11 at 14:33










  • I have my own scheme I need to know how the code will look like I need this to add in Jira custom field issues
    – m.nabil
    Nov 11 at 14:39














  • 2




    You forgot posting the code.
    – Foo
    Nov 11 at 13:58










  • All you have posted is a goal, but not any code related problems associated with achieving that goal as outlined in How to Ask and Minimal, Complete, and Verifiable example
    – charlietfl
    Nov 11 at 14:00












  • I select Opened Just Escalated and Deferred are only appear Ok. Why exactly these? According to what scheme?
    – Smollet777
    Nov 11 at 14:33










  • I have my own scheme I need to know how the code will look like I need this to add in Jira custom field issues
    – m.nabil
    Nov 11 at 14:39








2




2




You forgot posting the code.
– Foo
Nov 11 at 13:58




You forgot posting the code.
– Foo
Nov 11 at 13:58












All you have posted is a goal, but not any code related problems associated with achieving that goal as outlined in How to Ask and Minimal, Complete, and Verifiable example
– charlietfl
Nov 11 at 14:00






All you have posted is a goal, but not any code related problems associated with achieving that goal as outlined in How to Ask and Minimal, Complete, and Verifiable example
– charlietfl
Nov 11 at 14:00














I select Opened Just Escalated and Deferred are only appear Ok. Why exactly these? According to what scheme?
– Smollet777
Nov 11 at 14:33




I select Opened Just Escalated and Deferred are only appear Ok. Why exactly these? According to what scheme?
– Smollet777
Nov 11 at 14:33












I have my own scheme I need to know how the code will look like I need this to add in Jira custom field issues
– m.nabil
Nov 11 at 14:39




I have my own scheme I need to know how the code will look like I need this to add in Jira custom field issues
– m.nabil
Nov 11 at 14:39












1 Answer
1






active

oldest

votes

















up vote
0
down vote













How exactly you need them to disappear? Here i just delete them from the DOM.






const selector = document.querySelector("select");

selector.addEventListener("click", addActivityItem);

function addActivityItem(event) {
let options = selector.querySelectorAll("option");
for (let i = 0; i < options.length; i++) {
if (options[i].value !== event.target.value) options[i].remove()
}
}

<select>
<option>One</option>
<option>Two</option>
</select>








share|improve this answer























  • yes I need something like this but I need to choose which appear and which disappear
    – m.nabil
    Nov 11 at 14:28











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53249459%2fhow-can-i-change-select-options-with-javascript%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote













How exactly you need them to disappear? Here i just delete them from the DOM.






const selector = document.querySelector("select");

selector.addEventListener("click", addActivityItem);

function addActivityItem(event) {
let options = selector.querySelectorAll("option");
for (let i = 0; i < options.length; i++) {
if (options[i].value !== event.target.value) options[i].remove()
}
}

<select>
<option>One</option>
<option>Two</option>
</select>








share|improve this answer























  • yes I need something like this but I need to choose which appear and which disappear
    – m.nabil
    Nov 11 at 14:28















up vote
0
down vote













How exactly you need them to disappear? Here i just delete them from the DOM.






const selector = document.querySelector("select");

selector.addEventListener("click", addActivityItem);

function addActivityItem(event) {
let options = selector.querySelectorAll("option");
for (let i = 0; i < options.length; i++) {
if (options[i].value !== event.target.value) options[i].remove()
}
}

<select>
<option>One</option>
<option>Two</option>
</select>








share|improve this answer























  • yes I need something like this but I need to choose which appear and which disappear
    – m.nabil
    Nov 11 at 14:28













up vote
0
down vote










up vote
0
down vote









How exactly you need them to disappear? Here i just delete them from the DOM.






const selector = document.querySelector("select");

selector.addEventListener("click", addActivityItem);

function addActivityItem(event) {
let options = selector.querySelectorAll("option");
for (let i = 0; i < options.length; i++) {
if (options[i].value !== event.target.value) options[i].remove()
}
}

<select>
<option>One</option>
<option>Two</option>
</select>








share|improve this answer














How exactly you need them to disappear? Here i just delete them from the DOM.






const selector = document.querySelector("select");

selector.addEventListener("click", addActivityItem);

function addActivityItem(event) {
let options = selector.querySelectorAll("option");
for (let i = 0; i < options.length; i++) {
if (options[i].value !== event.target.value) options[i].remove()
}
}

<select>
<option>One</option>
<option>Two</option>
</select>








const selector = document.querySelector("select");

selector.addEventListener("click", addActivityItem);

function addActivityItem(event) {
let options = selector.querySelectorAll("option");
for (let i = 0; i < options.length; i++) {
if (options[i].value !== event.target.value) options[i].remove()
}
}

<select>
<option>One</option>
<option>Two</option>
</select>





const selector = document.querySelector("select");

selector.addEventListener("click", addActivityItem);

function addActivityItem(event) {
let options = selector.querySelectorAll("option");
for (let i = 0; i < options.length; i++) {
if (options[i].value !== event.target.value) options[i].remove()
}
}

<select>
<option>One</option>
<option>Two</option>
</select>






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 11 at 14:27

























answered Nov 11 at 14:19









Smollet777

921815




921815












  • yes I need something like this but I need to choose which appear and which disappear
    – m.nabil
    Nov 11 at 14:28


















  • yes I need something like this but I need to choose which appear and which disappear
    – m.nabil
    Nov 11 at 14:28
















yes I need something like this but I need to choose which appear and which disappear
– m.nabil
Nov 11 at 14:28




yes I need something like this but I need to choose which appear and which disappear
– m.nabil
Nov 11 at 14:28


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53249459%2fhow-can-i-change-select-options-with-javascript%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Xamarin.iOS Cant Deploy on Iphone

Glorious Revolution

Dulmage-Mendelsohn matrix decomposition in Python