Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 74020

Calling a function using 'option' of 'select' is not working [duplicate]

$
0
0

This question already has an answer here:

I have dynamic select (the values been inserted by Razor) and I try to call javascript function, but it's not working. The function doesn`t respond. I tried 'onclick' and 'onselect' - none of them worked. Am I missing somthing?

<select class="custom-select w-auto" id="AssetSelector">
 <option value="Deafult">Choose Asset</option>
 @foreach (var a in @Model.OwnAssetsList)
 {
  var AssetSerialModel = Newtonsoft.Json.JsonConvert.SerializeObject(a);

  <option onchange="ShowAssetDetails(@AssetSerialModel)" value=@a.AssetID>Asset No: @a.AssetID</option>
 }
 </select>


@section scripts
{
<script type="text/javascript">

    function ShowAssetDetails(asset)
    {
        console.log("check");
    }

</script>
}

Viewing all articles
Browse latest Browse all 74020

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>