locked
Dropdownlist using jquery RRS feed

  • Question

  • User1390323494 posted

    How to show only the selected option from the dropdownlist and remove button in the dropdown after an option has been selected?

    Tuesday, July 28, 2020 12:20 PM

Answers

  • User-2121988648 posted

    You can use onchange event through Javascript/Jquery and then perform this logic

    <select id="mySelect" onchange="myFunction()">
    <option value="A">A</option>
    <option value="B">B</option>
    <option value="C">C</option>
    <option value="D">D</option>
    </select>

    <div id="selected"></div>

    function myFunction() {

    var x = document.getElementById("mySelect").value;

    document.getElementById("selected").innerHTML = "You selected: " + x;

    //Your logic to hide 

    }

    Using jQuery:

    $('#mySelect').on('change', function() {
      alert( this.value );
    //Hide Logic });
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, July 28, 2020 12:44 PM

All replies

  • User475983607 posted

    How to show only the selected option from the dropdownlist and remove button in the dropdown after an option has been selected?

    Can you share your code so we can have an idea of what you are trying to do?

    Tuesday, July 28, 2020 12:35 PM
  • User-2121988648 posted

    You can use onchange event through Javascript/Jquery and then perform this logic

    <select id="mySelect" onchange="myFunction()">
    <option value="A">A</option>
    <option value="B">B</option>
    <option value="C">C</option>
    <option value="D">D</option>
    </select>

    <div id="selected"></div>

    function myFunction() {

    var x = document.getElementById("mySelect").value;

    document.getElementById("selected").innerHTML = "You selected: " + x;

    //Your logic to hide 

    }

    Using jQuery:

    $('#mySelect').on('change', function() {
      alert( this.value );
    //Hide Logic });
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, July 28, 2020 12:44 PM
  • User1390323494 posted

    Thank you, this helps

    Tuesday, July 28, 2020 12:47 PM
  • User-2121988648 posted

    Please mark it as solved if your issue is resolved :)

    Tuesday, July 28, 2020 12:54 PM