Reputation: 294
I have problem with getting values from select option when use JQuery UI $('#id').combobox(). When i use simple JQuery without Ui it work but when i use Ui it can't get Value. Here some of my HTML code:
<table>
<tr>
<td>Reset by: </td>
<td>
<select name="resetType" id="resetType">
<option value="email" selected>Email</option>
<option value="phone">Phone's Number</option>
<option value="username">Username</option>
</select>
</td>
</tr>
<tr>
<td id="type"></td>
<td><input type="text" name="type"/></td>
</tr>
</table>
Here my JQuery Code:
$(function(){
$('#resetType').combobox(); // Code have Problem
switch($('#resetType').val()){
case 'email':
$('#type').html('Email: ');
break;
case 'phone':
$('#type').html('Phone: ');
break;
case 'username':
$('#type').html('Username: ');
break;
}
})
Upvotes: 2
Views: 3072
Reputation: 67021
I did [name*="type"]
here because you didn't give that textbox an ID or anything, so i'm simply searching for it by name
attribute.
$('#resetType').on('change', function () {
$('[name*="type"]').val($(this).find('option:selected').val());
});
Here's a working demo: http://jsfiddle.net/JwB6z/2/
Upvotes: 1