Topic: combobox filter Pages that link to <a href="https://ozoneasylum.com/backlink?for=31087" title="Pages that link to Topic: combobox filter" rel="nofollow" >Topic: combobox filter\

 
Author Thread
Arthurio
Paranoid (IV) Inmate

From: cell 3736
Insane since: Jul 2003

IP logged posted posted 06-30-2009 09:31 Edit Quote

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

IP logged posted posted 06-30-2009 10:12 Edit Quote

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

IP logged posted posted 06-30-2009 15:38 Edit Quote

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

IP logged posted posted 06-30-2009 15:52 Edit Quote

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

IP logged posted posted 06-30-2009 18:55 Edit Quote

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

IP logged posted posted 07-01-2009 12:05 Edit Quote

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

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


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


« BackwardsOnwards »

Show Forum Drop Down Menu