I’ having problems getting the selected value from an autocomplete-combobox jquery widget.
Although I’ve been changing things a little bit, the original code-demo is this.
According to the code, the written/validated value should be stored in ui.item.option But it seems I’m not able to access it and store it in a label/hidden field for later usage at codebehind.
<script type="text/javascript">
$(document).ready(
function() {
$('select[name=combobox]').change(
function(){
var newText = $('ui.item.option', this).text();
$('#MyLabel').text(newText);
}
);
}
);
</script>
combobox is the id/name for the value list in aspx page
It’s not working, any help? Thanks.
EDIT
This are the listed items (using demo example)
<select id="combobox" name="combobox">
<option value="">Select one...</option>
<option value="ActionScript">ActionScript</option>
<option value="AppleScript">AppleScript</option>
<option value="Asp">Asp</option>
<option value="BASIC">BASIC</option>
<option value="C">C</option>
<option value="C++">C++</option>
<option value="Clojure">Clojure</option>
<option value="COBOL">COBOL</option>
<option value="ColdFusion">ColdFusion</option>
<option value="Erlang">Erlang</option>
<option value="Fortran">Fortran</option>
<option value="Groovy">Groovy</option>
<option value="Haskell">Haskell</option>
<option value="Java">Java</option>
<option value="JavaScript">JavaScript</option>
<option value="Lisp">Lisp</option>
<option value="Perl">Perl</option>
<option value="PHP">PHP</option>
<option value="Python">Python</option>
<option value="Ruby">Ruby</option>
<option value="Scala">Scala</option>
<option value="Scheme">Scheme</option>
</select>
don’t use JS event change. Set UI event when creating autocomplete:
I see now. I’m not sure this is the best example to start with but your choice 🙂
You need to create widget event and call it ( i give you just small parts of demo code becouse is too big ):
Create default Event for select:
try to call it if event is defined :
when creating combobox overide your default select method:
try this 🙂
EDIT//
See full code. It works for me: