Topic: combobox filter (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=31087" title="Pages that link to Topic: combobox filter (Page 1 of 1)" rel="nofollow" >Topic: combobox filter <span class="small">(Page 1 of 1)</span>\

 
Arthurio
Paranoid (IV) Inmate

From: cell 3736
Insane since: Jul 2003

posted posted 06-30-2009 09:31

I want to filter the items in a combo box based on partial, case-insensitive strings in a text box in real time using javascript. I don't know how to do it tho.

I want to do something like this:

[FILTER FIELD]
[COMBO BOX]

Initially the combo box has values: Asia, Africa, Americas, Europe.

When I type "a" into the search field the combo box should display only: Asia, Africa, Americas. When I type "as" it should display: Asia, Americas. And when I type "" again it should display all the initial options.

help!

Tyberius Prime
Maniac (V) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 06-30-2009 10:12

simple, keep all you key=>value mappings in an object,

then

code:
comboBox.options = []; // or similar, don't know exactly. Clear the combobox anyhow.
for (key in myEntries)
{
   if (shouldBeShown(key))
     comboBox.options[length(comboBox.options)] = ...
}


call that onChange, and you're done.

Arthurio
Paranoid (IV) Inmate

From: cell 3736
Insane since: Jul 2003

posted posted 06-30-2009 15:38

thanks
here's what I have so far

now what would be the best way to pass all the selected items' values as post/get parameters if I can't change how the submit button functions

I'm thinking maybe I could hide a duplicate of the selected items list and keep all the items selected in there. Any better ideas?

Tyberius Prime
Maniac (V) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 06-30-2009 15:52

I do not understand your question.
SelectedItems.values should already be transmitted as $_POST['selectedItems']...

Arthurio
Paranoid (IV) Inmate

From: cell 3736
Insane since: Jul 2003

posted posted 06-30-2009 18:55

nope, i don't want the items that are actually selected, i want all the items that are in the left combobox that is named "selected items"

Tyberius Prime
Maniac (V) Mad Scientist with Finglongers

From: Germany
Insane since: Sep 2001

posted posted 07-01-2009 12:05

if you can't assign an onsumbit handler (which is what I'd do),
you'll have to update a hidden variable whenever the contens changes,
perhaps simply by
x = new Array();
for (option in .selectedItems) //use appropriate code here
x[length(x)] = option;
hiddenField.value = x.join(",");

provided you don't have any ',' in your values

coach
Nervous Wreck (II) Inmate

From:
Insane since: May 2011

posted posted 05-31-2011 11:07
Edit TP: spam removed


Post Reply
 
Your User Name:
Your Password:
Login Options:
 
Your Text:
Loading...
Options:


« BackwardsOnwards »

Show Forum Drop Down Menu