Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
125
rated 0 times [  131] [ 6]  / answers: 1 / hits: 15138  / 10 Years ago, tue, december 23, 2014, 12:00:00

I tried to made text input that filtering selectbox.
I'm trying to fix it alot of time but it still not working well.
Maybe because it is in hebrew?



HTML:



<option value=628077> new york</option>
<option value=244228>רמת גן<option>
<option value=641332> דימונה</option>
<option value=240812> הזורעים</option>
.
.
.
<option value=640375> עתניאל</option>
<option value=344580> חיפה</option>
<option value=440560> בית רבן</option>
<option value=520098> הרצליה</option>
</select>


jQuery:



<script type=text/javascript >
$('#city').keyup(function () {

var valthis = $(this).val();
var num = 0;
$('select#DropDownList1>option').each(function () {
var text = $(this).text();
if(text.indexOf(valthis) != -1)
{ $(this).show();}
else{ $(this).hide();}

});

});
</script>


I need your help!


More From » jquery

 Answers
148
$('#city').keyup(function () {
var valthis = $(this).val().toLowerCase();

$('select#DropDownList1>option').each(function () {
var text = $(this).text().toLowerCase();
if (text.indexOf(valthis) !== -1) {
$(this).show(); $(this).prop('selected',true);
}
else {
$(this).hide();
}
});
});


DEMO Hope it helps.


[#68409] Friday, December 19, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
dayana

Total Points: 302
Total Questions: 102
Total Answers: 100

Location: Cayman Islands
Member since Fri, Mar 4, 2022
2 Years ago
dayana questions
Sun, Apr 4, 21, 00:00, 3 Years ago
Fri, Aug 21, 20, 00:00, 4 Years ago
Fri, Aug 21, 20, 00:00, 4 Years ago
;