I am using Polymer's paper dropdown menu in my application and it has a list of integers as paper-items. I am trying to extract the selected value from the dropdown, but I always get this error :
Type Error : Undefined is not an object.
The code I am using is this :
<paper-dropdown-menu id="dropmenu" label="Select Here ">
<paper-dropdown class="dropdown">
<core-menu class="menu">
<paper-item>0.405</paper-item>
<paper-item>0.540</paper-item>
and so on..
and for JS :
<script type="text/javascript">
function getDropdownVal()
{
var f = function()
{
var dropd = document.querySelector('#dropmenu').detail.item;
var x = dropd.value;
var y = parseInt(x);
alert("Selected item is" +y);
};
f();
};
</script>
What am I doing wrong ? How do I fix this ?
Thanks !
has an selectedItemLabel property which gives you the label of the selected item.
You can simply parse it using javascript.
var selectedItem = document.querySelector('paper-dropdown-menu').selectedItemLabel;
var result= parseInt(selectedItem);
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加