Clear 2nd Dropdown values based on 1st Dropdown valueWhat are valid values for the id attribute in HTML?Which “href” value should I use for JavaScript links, “#” or “javascript:void(0)”?Set a default parameter value for a JavaScript functionHow can I get query string values in JavaScript?Get selected value in dropdown list using JavaScriptSort array of objects by string property valueHow to style a <select> dropdown with only CSS?Copy array by valuejQuery Get Selected Option From DropdownHow to - Make 1st dynamic dropdown MUST to select from 2nd dropdown?

How can glass marbles naturally occur in a desert?

What are good ways to improve as a writer other than writing courses?

Is it allowed and safe to carry a passenger / non-pilot in the front seat of a small general aviation airplane?

What are the examples (applications) of the MIPs in which the objective function has nonzero coefficients for only continuous variables?

Can I enter a rental property without giving notice if I'm afraid a tenant may be hurt?

Japanese equivalent of a brain fart

Finish the Mastermind

What does VB stand for?

HttpResponse[Status=BAD_REQUEST, StatusCode=400]

How does The Fools Guild make its money?

What are these mathematical groups in U.S. universities?

Our group keeps dying during the Lost Mine of Phandelver campaign. What are we doing wrong?

WordCloud: do not eliminate duplicates

In the movie Harry Potter and the Order or the Phoenix, why didn't Mr. Filch succeed to open the Room of Requirement if it's what he needed?

How to explain to a team that the project they will work for 6 months will 100% fail?

Why are the inside diameters of some pipe larger than the stated size?

Does this put me at risk for identity theft?

Colleagues speaking another language and it impacts work

Can a character take on additional backgrounds, or at least their benefits?

Is it true that control+alt+delete only became a thing because IBM would not build Bill Gates a computer with a task manager button?

How is the return type of a ternary operator determined?

Why does putting a dot after the URL remove login information?

Why can I log in to my Facebook account with a misspelled email/password?

Did silent film actors actually say their lines or did they simply improvise “dialogue” while being filmed?



Clear 2nd Dropdown values based on 1st Dropdown value


What are valid values for the id attribute in HTML?Which “href” value should I use for JavaScript links, “#” or “javascript:void(0)”?Set a default parameter value for a JavaScript functionHow can I get query string values in JavaScript?Get selected value in dropdown list using JavaScriptSort array of objects by string property valueHow to style a <select> dropdown with only CSS?Copy array by valuejQuery Get Selected Option From DropdownHow to - Make 1st dynamic dropdown MUST to select from 2nd dropdown?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















When I select 1st Dropdown, I need to clear 2nd Dropdown.



I had used .empty() method but if I use this method later on I am not getting 2nd dropdown values.



I've tried the following method:



 $("#taskcategorylist").change(function () 
console.log("Task Category Changed");
$('#tasktypes').val("");
);


1st dropdown Html code:



 <div class="field">
<b>Task Category</b>
<div class="ui selection dropdown">
<i class="dropdown icon"></i>
<div class="default text">Select</div>
<div class="menu" id="taskcategorylist"></div>
</div>
</div>


2nd dropdown Html code:



 <div class="field">
<b>Task Type</b>
<div class="ui selection dropdown">
<i class="dropdown icon"></i>
<div class="default text">Select</div>
<div class="menu" id="tasktypes"></div>
</div>
</div>


1st dropdown Jquery code:



 $.get(window.routemap + "api/task/taskcategory", function (data) 
self.taskcategorylist = JSON.parse(data.Data).Lookup;
self.taskcategorylist.forEach(function (item)
$('#taskcategorylist').append("<div class='item' data-value='" +
item.category_id + "'> " + item.category_name + "</div >");
);
);


2nd dropdown Jquery code:



$.get(window.routemap + "api/firm/tasktypes", function (data) 
self.tasktypes = JSON.parse(data.Data).Lookup;
self.tasktypes.forEach(function (data)
$('#tasktypes').append("<div class='item' data-value='" +
data.tasktype_id + "'> " + data.task_name + "</div >");
);
);









share|improve this question
































    0















    When I select 1st Dropdown, I need to clear 2nd Dropdown.



    I had used .empty() method but if I use this method later on I am not getting 2nd dropdown values.



    I've tried the following method:



     $("#taskcategorylist").change(function () 
    console.log("Task Category Changed");
    $('#tasktypes').val("");
    );


    1st dropdown Html code:



     <div class="field">
    <b>Task Category</b>
    <div class="ui selection dropdown">
    <i class="dropdown icon"></i>
    <div class="default text">Select</div>
    <div class="menu" id="taskcategorylist"></div>
    </div>
    </div>


    2nd dropdown Html code:



     <div class="field">
    <b>Task Type</b>
    <div class="ui selection dropdown">
    <i class="dropdown icon"></i>
    <div class="default text">Select</div>
    <div class="menu" id="tasktypes"></div>
    </div>
    </div>


    1st dropdown Jquery code:



     $.get(window.routemap + "api/task/taskcategory", function (data) 
    self.taskcategorylist = JSON.parse(data.Data).Lookup;
    self.taskcategorylist.forEach(function (item)
    $('#taskcategorylist').append("<div class='item' data-value='" +
    item.category_id + "'> " + item.category_name + "</div >");
    );
    );


    2nd dropdown Jquery code:



    $.get(window.routemap + "api/firm/tasktypes", function (data) 
    self.tasktypes = JSON.parse(data.Data).Lookup;
    self.tasktypes.forEach(function (data)
    $('#tasktypes').append("<div class='item' data-value='" +
    data.tasktype_id + "'> " + data.task_name + "</div >");
    );
    );









    share|improve this question




























      0












      0








      0


      1






      When I select 1st Dropdown, I need to clear 2nd Dropdown.



      I had used .empty() method but if I use this method later on I am not getting 2nd dropdown values.



      I've tried the following method:



       $("#taskcategorylist").change(function () 
      console.log("Task Category Changed");
      $('#tasktypes').val("");
      );


      1st dropdown Html code:



       <div class="field">
      <b>Task Category</b>
      <div class="ui selection dropdown">
      <i class="dropdown icon"></i>
      <div class="default text">Select</div>
      <div class="menu" id="taskcategorylist"></div>
      </div>
      </div>


      2nd dropdown Html code:



       <div class="field">
      <b>Task Type</b>
      <div class="ui selection dropdown">
      <i class="dropdown icon"></i>
      <div class="default text">Select</div>
      <div class="menu" id="tasktypes"></div>
      </div>
      </div>


      1st dropdown Jquery code:



       $.get(window.routemap + "api/task/taskcategory", function (data) 
      self.taskcategorylist = JSON.parse(data.Data).Lookup;
      self.taskcategorylist.forEach(function (item)
      $('#taskcategorylist').append("<div class='item' data-value='" +
      item.category_id + "'> " + item.category_name + "</div >");
      );
      );


      2nd dropdown Jquery code:



      $.get(window.routemap + "api/firm/tasktypes", function (data) 
      self.tasktypes = JSON.parse(data.Data).Lookup;
      self.tasktypes.forEach(function (data)
      $('#tasktypes').append("<div class='item' data-value='" +
      data.tasktype_id + "'> " + data.task_name + "</div >");
      );
      );









      share|improve this question
















      When I select 1st Dropdown, I need to clear 2nd Dropdown.



      I had used .empty() method but if I use this method later on I am not getting 2nd dropdown values.



      I've tried the following method:



       $("#taskcategorylist").change(function () 
      console.log("Task Category Changed");
      $('#tasktypes').val("");
      );


      1st dropdown Html code:



       <div class="field">
      <b>Task Category</b>
      <div class="ui selection dropdown">
      <i class="dropdown icon"></i>
      <div class="default text">Select</div>
      <div class="menu" id="taskcategorylist"></div>
      </div>
      </div>


      2nd dropdown Html code:



       <div class="field">
      <b>Task Type</b>
      <div class="ui selection dropdown">
      <i class="dropdown icon"></i>
      <div class="default text">Select</div>
      <div class="menu" id="tasktypes"></div>
      </div>
      </div>


      1st dropdown Jquery code:



       $.get(window.routemap + "api/task/taskcategory", function (data) 
      self.taskcategorylist = JSON.parse(data.Data).Lookup;
      self.taskcategorylist.forEach(function (item)
      $('#taskcategorylist').append("<div class='item' data-value='" +
      item.category_id + "'> " + item.category_name + "</div >");
      );
      );


      2nd dropdown Jquery code:



      $.get(window.routemap + "api/firm/tasktypes", function (data) 
      self.tasktypes = JSON.parse(data.Data).Lookup;
      self.tasktypes.forEach(function (data)
      $('#tasktypes').append("<div class='item' data-value='" +
      data.tasktype_id + "'> " + data.task_name + "</div >");
      );
      );






      javascript jquery html css semantic-ui






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 27 at 7:54









      piet.t

      10.2k7 gold badges36 silver badges48 bronze badges




      10.2k7 gold badges36 silver badges48 bronze badges










      asked Mar 27 at 6:06









      Yathish kumarYathish kumar

      405 bronze badges




      405 bronze badges

























          1 Answer
          1






          active

          oldest

          votes


















          2














          Try this code.



          $("#taskcategorylist").change(function () 
          console.log("Task Category Changed");

          $('#tasktypes').parents(".ui.dropdown").dropdown('clear');
          );





          share|improve this answer

























          • no luck its not working.

            – Yathish kumar
            Mar 27 at 6:37











          • What's not working? I'm using the same framework, and I'm using same kind of approach that you are using, this code is working for me, can you show us working demo or snippet, so It would be easy to debug the problem

            – Abhishek Pandey
            Mar 27 at 6:41







          • 1





            Yes its works now i made mistake in the events, your answer exactly works for me has expected, Thank you.

            – Yathish kumar
            Mar 27 at 6:58










          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',
          autoActivateHeartbeat: false,
          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%2f55370785%2fclear-2nd-dropdown-values-based-on-1st-dropdown-value%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









          2














          Try this code.



          $("#taskcategorylist").change(function () 
          console.log("Task Category Changed");

          $('#tasktypes').parents(".ui.dropdown").dropdown('clear');
          );





          share|improve this answer

























          • no luck its not working.

            – Yathish kumar
            Mar 27 at 6:37











          • What's not working? I'm using the same framework, and I'm using same kind of approach that you are using, this code is working for me, can you show us working demo or snippet, so It would be easy to debug the problem

            – Abhishek Pandey
            Mar 27 at 6:41







          • 1





            Yes its works now i made mistake in the events, your answer exactly works for me has expected, Thank you.

            – Yathish kumar
            Mar 27 at 6:58















          2














          Try this code.



          $("#taskcategorylist").change(function () 
          console.log("Task Category Changed");

          $('#tasktypes').parents(".ui.dropdown").dropdown('clear');
          );





          share|improve this answer

























          • no luck its not working.

            – Yathish kumar
            Mar 27 at 6:37











          • What's not working? I'm using the same framework, and I'm using same kind of approach that you are using, this code is working for me, can you show us working demo or snippet, so It would be easy to debug the problem

            – Abhishek Pandey
            Mar 27 at 6:41







          • 1





            Yes its works now i made mistake in the events, your answer exactly works for me has expected, Thank you.

            – Yathish kumar
            Mar 27 at 6:58













          2












          2








          2







          Try this code.



          $("#taskcategorylist").change(function () 
          console.log("Task Category Changed");

          $('#tasktypes').parents(".ui.dropdown").dropdown('clear');
          );





          share|improve this answer













          Try this code.



          $("#taskcategorylist").change(function () 
          console.log("Task Category Changed");

          $('#tasktypes').parents(".ui.dropdown").dropdown('clear');
          );






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 27 at 6:22









          Abhishek PandeyAbhishek Pandey

          10.4k8 gold badges23 silver badges51 bronze badges




          10.4k8 gold badges23 silver badges51 bronze badges















          • no luck its not working.

            – Yathish kumar
            Mar 27 at 6:37











          • What's not working? I'm using the same framework, and I'm using same kind of approach that you are using, this code is working for me, can you show us working demo or snippet, so It would be easy to debug the problem

            – Abhishek Pandey
            Mar 27 at 6:41







          • 1





            Yes its works now i made mistake in the events, your answer exactly works for me has expected, Thank you.

            – Yathish kumar
            Mar 27 at 6:58

















          • no luck its not working.

            – Yathish kumar
            Mar 27 at 6:37











          • What's not working? I'm using the same framework, and I'm using same kind of approach that you are using, this code is working for me, can you show us working demo or snippet, so It would be easy to debug the problem

            – Abhishek Pandey
            Mar 27 at 6:41







          • 1





            Yes its works now i made mistake in the events, your answer exactly works for me has expected, Thank you.

            – Yathish kumar
            Mar 27 at 6:58
















          no luck its not working.

          – Yathish kumar
          Mar 27 at 6:37





          no luck its not working.

          – Yathish kumar
          Mar 27 at 6:37













          What's not working? I'm using the same framework, and I'm using same kind of approach that you are using, this code is working for me, can you show us working demo or snippet, so It would be easy to debug the problem

          – Abhishek Pandey
          Mar 27 at 6:41






          What's not working? I'm using the same framework, and I'm using same kind of approach that you are using, this code is working for me, can you show us working demo or snippet, so It would be easy to debug the problem

          – Abhishek Pandey
          Mar 27 at 6:41





          1




          1





          Yes its works now i made mistake in the events, your answer exactly works for me has expected, Thank you.

          – Yathish kumar
          Mar 27 at 6:58





          Yes its works now i made mistake in the events, your answer exactly works for me has expected, Thank you.

          – Yathish kumar
          Mar 27 at 6:58








          Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







          Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















          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.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55370785%2fclear-2nd-dropdown-values-based-on-1st-dropdown-value%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

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

          Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript