i'm using jquery ui selectmenu().
i gone through https://jqueryui.com/selectmenu/
i have 2 select box. want use 1st selectbox value in second. how can value of 1st selectbox.
for temporary i'm doing this.
<select class="select" id="one"> <option value="1">a</option> <option value="2">b</option> </select> <select class="select2"> <option value="1">a</option> <option value="2">b</option> </select> $(".select").selectmenu(); $(".select2").selectmenu({ change: function (event, data) { var firstval = $("#one-button .ui-selectmenu-text").text(); alert(firstval); return false; } });
is there better way value of first selectbox?
it's generating below kind of html
<span class="ui-selectmenu-button ui-widget ui-state-default ui-corner-all" tabindex="0" id="one-button" role="combobox" aria-expanded="false" aria-autocomplete="list" aria-owns="continents_1-menu" aria-haspopup="true" style="width: 0px;" aria-activedescendant="ui-id-29" aria-labelledby="ui-id-29" aria-disabled="false"> <span class="ui-icon ui-icon-triangle-1-s"></span> <span class="ui-selectmenu-text">1</span> </span>
you can value of select element, selectui updates value of underlying select element.
var firstval = $("#one").val();
demo: fiddle
Comments
Post a Comment