Click here to Skip to main content
15,881,938 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have two select options with 2 different js function codes, But 2 select options are same one is doing count and another one is using to show the locations in map. I need to combine both select option as common, like if i choose abinash to the count and as well as locations in map.

Thanks in advance

What I have tried:

HTML
<pre> </div class="form-group">
        <div class="">
          <label  class="text-center p-1" for="category_state">Select Regional IT </label>
          <select id="category_itrep" onchange="filterMarkers(this.value);" >
              <option value="">Please select RIT wise</option>
              <option value="Abinash">Abinash</option>
              <option value="Jayakumar">Jayakumar</option>
              <option value="KA_Vacant">KA_Vacant</option>
              <option value="Manmohan">Manmohan</option>
              <option value="Narayanan">Narayanan</option>
              <option value="Nisvanth Kanna">Nisvanth Kanna</option>
              <option value="Rajkumar Kalal">Rajkumar Kalal</option>
              <option value="Ranjan Kumar">Ranjan Kumar</option>
              <option value="Ravikumar">Ravikumar</option>
              <option value="SP_Vacant">SP_Vacant</option>
              <option value="Thakar Sapan">Thakar Sapan</option>
              <option value="TN_Vacant">TN_Vacant</option>
              <option value="Yogesh">Yogesh</option>
          </select>

        </div> </br>
  <div class="form-group">
      <div class="">
      <select id="mySelectElement" onchange="myFunction()"> <option value="">Please select RIT wise</option>
              <option value="Abinash">Abinash</option>
              <option value="Jayakumar">Jayakumar</option>
              <option value="KA_Vacant">KA_Vacant</option>
              <option value="Manmohan">Manmohan</option>
              <option value="Narayanan">Narayanan</option>
              <option value="Nisvanth Kanna">Nisvanth Kanna</option>
              <option value="Rajkumar Kalal">Rajkumar Kalal</option>
              <option value="Ranjan Kumar">Ranjan Kumar</option>
              <option value="Ravikumar">Ravikumar</option>
              <option value="SP_Vacant">SP_Vacant</option>
              <option value="Thakar Sapan">Thakar Sapan</option>
              <option value="TN_Vacant">TN_Vacant</option>
              <option value="Yogesh">Yogesh</option>  </select>
      <h6> Total Number of Branches attend by the specified RIT:
          <span id="branch_counts">0</span> </h6>
      </div>
  </div>
      </div>
Posted
Updated 26-Sep-19 3:08am

1 solution

Rather than using the onchange attribute, attach to the change event via your js code itself

JavaScript DOM EventListener[^]

That will allow you to attach multiple subscribers to the same event. Just make sure the element exists before your js runs, ie it is before it on the page.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900