Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to call a javascript function using asp.net dropdown list

I need to call a javascript function when the dropdown list is changed.

How can I implement that in asp.net?

like image 928
Optimus Avatar asked Jul 13 '26 21:07

Optimus


1 Answers

Use onchange event to excecute function whenever the dropdown list clicked.

<select id="mylist" onchange = "go()">
<option value="value1">value1</option>
<option value="value2">value2</option>
</select>

<script>
  function go()
  {
    var x = document.getElementById("mylist").value;
    console.log(x);
  }
</script>
like image 133
Stardust Avatar answered Jul 15 '26 12:07

Stardust



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!