how to pick different API calls depending on the drop down option

how to pick different API calls depending on the drop down option

By : user2185136
Date : November 20 2020, 04:01 AM
like below fixes the issue You can use jQuery's .change() event, and then use this.value to check which option was selected and thus run the corresponding API call using an if statement.
See example below:
code :
$("#hierarchy").change(function() { // Run this function when option selected
  let position = this.value;
  if(position == "Staff") {
    api_login('usa'/*ADD OTHER ARUGMENTS HERE*/);
  } else if(position == "Teacher") {
    api_login('france'/*ADD OTHER ARUGMENTS HERE*/);
  } else if(position == "Student") {
    api_login('uk'/*ADD OTHER ARUGMENTS HERE*/);
  } else {
    console.log("Stop/Don't run any API's");

function api_login(country, dealer_code, userid_code, actionID = '10', VRN = '', filename = '') { /* ADD country AS A FIRST ARGUMENT */
  if (dealer_code === undefined || userid_code === undefined) {
    return false;
  if (actionID === undefined) {
    actionID = '10';
  var string = 'dealerID=' + dealer_code + '&salesExecID=' + userid_code + '&actionID=' + actionID + '&VRM=' + VRN + '&filename=' + filename;
  var querystring = country +'.snstest.judgeservice.co.uk/api.php?' + (string); /* CHANGE THIS LINE TO USE country */
  var error = [];

  $.getJSON(querystring, function(json) {
    var response = String(json.code);
    var message = String(json.message);
    var ident = String(json.identifier);
    var username = String(json.accountName);
    var siteName = String(json.siteName);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<label for="Hierarchy">hierarchy</label>
<select name="hierarchy" id="hierarchy" value="">
  <option value=""></option>
  <option value="Staff">staff</option>
  <option value="Teacher"> teacher</option>
  <option value="Student">student</option>

uk.snstest.judgeservice.co.uk/api.php? usa.snstest.judgeservice.co.uk/api.php? france.snstest.judgeservice.co.uk/api.php? so depedning what country
student=uk staff=usa teacher=france

Share : facebook icon twitter icon
Change items in a drop-down list depending on the selected option in another drop-down list

Change items in a drop-down list depending on the selected option in another drop-down list

By : jokinawa
Date : March 29 2020, 07:55 AM
With these it helps I have the following code:
code :
<script type="text/javascript">
    $(function() {
      $("#form_process").click(function() {
        //$("#choice").val(); //you cannot use the same id for more than 1 tag
        var choice = 0; 
             if(document.getElementById("choice1").checked) choice='Yes';
        else if(document.getElementById("choice2").checked) choice='No';
        else if(document.getElementById("choice3").checked) choice='Dont Know';

        var comments = document.getElementById('comments').value; //$("#comments").val();
        var dataString = 'choice='+ choice + '&comments=' + comments;

          type: "POST",
          url: "**ABSOLUTE URL TO PROCESSOR**",
          data: dataString
HTML. Hide/Show a drop down menu depending on if an option is selected on another drop down menu

HTML. Hide/Show a drop down menu depending on if an option is selected on another drop down menu

By : Jakob Stanely
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further Modify the two dropdowns with attribute style="display:none". In your javascript function you would have an event registered that based on the SelectedIndex you would choose which dropdown element to remove the style="display:none" from.
Prevent Pick from Drop-down List Option in Excel

Prevent Pick from Drop-down List Option in Excel

By : user3412430
Date : March 29 2020, 07:55 AM
I wish did fix the issue. I have created a form that to be used by my company's employees. One employee noticed that when right clicking on a cell, there is a "Pick From Drop-down List..." option in the menu. When using that option it will sometimes show some seemingly random options from elsewhere on the spreadsheet. , Make that given option not visible with:
code :
With Application.CommandBars("Cell")
        .Controls("Pick from drop-down list...").Visible = False
End With
The drop down option should display depending on the previous option

The drop down option should display depending on the previous option

By : kamelija77
Date : March 29 2020, 07:55 AM
it fixes the issue First thing is your question is not clear . And I'm assuming as per your previous comments you want to hide drop down box if principle option is selected in first drop down box. here is your simple answer.
code :
         <select id="designation" onchange="showDropDown()"><br>
            <option value="hod">HOD</option>
            <option value="principal">Principal</option>
        <select id="pepartments">
            <option value="architecture">Architecture</option>
            <option value="biotech">Bio-Technology</option>
            <option value="chemical">Chemical Engineering</option>
            <option value="chemistry">Chemistry</option>
            <option value="civil">Civil Engineering</option>
            <option value="computerapp">Computer Applications</option>
            <option value="computerscience">Computer Science and Engineering</option>
            <option value="CSE">Electricals and Electronics</option>
            <option value="CSE">Electronics and Communication Engineering</option>
            <option value="CSE">Information Science and Engineering</option>
            <option value="CSE">Instrumentation and Electronics Engineering</option>
            <option value="CSE">Management Studies and Research Center</option>
            <option value="CSE">Mathematics</option>
            <option value="CSE">Mechanical Engineering</option>
            <option value="CSE">Medical Electronics</option>
            <option value="CSE">Physics</option>
            <option value="CSE">Telecommunication Engineering</option>              
            <option value="CSE">Physical education and Sports Sciences </option>
     <script type="text/javascript">
     function  showDropDown()  {     
       var seelecDsg = document.getElementById("designation").value;  
         if(seelecDsg == "hod"){
        	 document.getElementById("pepartments").style.display = 'block';
        	 document.getElementById("pepartments").style.display ="none";

Select onchange calls method with value depending on option

Select onchange calls method with value depending on option

By : Thomas Green
Date : March 29 2020, 07:55 AM
Hope that helps I would recommend you to use custom data-*attribute to persist arbitrary information which can be retrived later by using .data(key)
As you don't want to modify the doSomething method, attach another click handler. You can target the option using :selected selector
code :
$('#yourSelect').on('change', function() {
  //Retrieve data
  var json = $(this).find(':selected').data('json');
  //call the method 

function doSomething(json) {
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<select id="yourSelect">
  <option value="1" data-json='{"key": "json1"}'>name 1</option>
  <option value="2" data-json='{"key": "json2"}'>name 2</option>
Related Posts Related Posts :
  • Knockout JS: adding forms in foreach bindings
  • HTML5 Canvas positioning mouse clicking broken
  • JQuery on change fired only after second change of select box
  • Unable to limit WebRTC P2P Multi-participant Receiving Bandwidth
  • What is the RegEx to just return the last part of the URL
  • State Remains Undefined in React
  • removing content on website before a screen reader can read it with either JavaScript or CSS...?
  • on 'click' firing before click
  • Manipulation of an array sent by ajax to a php file, within a function of another file
  • How to use plunker or jsfiddle to run angular2 code
  • JavaScript lexical environments as objects
  • Iteratively position spheres with DOM pixels using three.js and React
  • React trying to access file at a wrong path
  • AES encryption in JS equivalent of C#
  • Filter an Array based off user input string and menu dropdown items
  • Constantly read local file with JS?
  • React navbar handler with theme
  • Show changes to HTML5 canvas immediately
  • Tooltip Stays Hidden In D3 Treemap
  • Backbone - What is the best way to listen to 2 models?
  • formatting an array of objects output
  • Bind input value to specific value in object
  • Animation doesnt work when onClick event occurs (react.js)
  • Consume enum from ambient TypeScript module using @babel/preset-typescript?
  • Changing order of React components only triggers re-render after second click
  • Track the total time the HTMLAudio was playing
  • Call javascript function in PHP file and load html file after?
  • Theme Development: JavaScript not working when linked from functions.php
  • Add attributes to multiple <td> in datatables
  • Progressive loading codesnip not quite understood
  • How to format default date in javascript?
  • Caesar cipher only gets first value right
  • innerText not showing after setting it straight after creating the element
  • How to use HTML template tag with jQuery?
  • Showing v-menue's selected option in another part of the application. Vuetify
  • How can I find and return my div element with rails and javascript?
  • The right way to use Ajax to Update a Single field in a specific Object
  • Hhow to create a react element and apply a javascript method to it
  • Change src of parent window iframe
  • How do you bind a style attribute if data is true?
  • JavaScript TypeError: Cannot read property 'id' of undefined
  • Use font-face with webpack encore
  • Best way to replace all characters from left to right?
  • Update React component with javascript
  • How to make a get route like "router.get('/region/:id')" but with a limited range for the id?
  • Attribute Value in Javascript
  • Add new property to object collection based on condition with lodash
  • Transforming an object with a javascript class
  • Why does the hash compare outputs true even without the salt parameter?
  • Moment.js comparison always returns false
  • Store polygon type of data on the `SQLite` database
  • Matching data depending on chosen preferences
  • issue which is related to vuex store + cookies
  • Order By custom order in object inside property
  • How to display a preselected value in a dropdown without 'onchange'
  • Storing a javascript promise
  • Replacing text in nested divs
  • Strange behavior with select list options when adding and removing tasks using javascript
  • NodeJS Ajv module alway log message ' $ref: keywords ignored in schema at path "#" '
  • How to create TTL Index on long timestamp in MongoDB
  • shadow
    Privacy Policy - Terms - Contact Us © bighow.org