ComboBox - need to get different values on select than displayed

View: New views
5 Messages — Rating Filter:   Alert me  

ComboBox - need to get different values on select than displayed

by theKryz :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I am using the Dojo ComboBox for convenience - because it looks better than the normal ComboBox (fits to text width).

However, when building my ComboBox Content, I realized, that the "onChange"-Javascript-Function is called with only the parameter: the content text of the selected <option>-tag. I need to set another value to one tag, that is given to the function though.

--> One that is displayed and one that is passed to the function, but otherwise hidden.

How can I do this?
I bet there's a really simple solution.

Thanks for any help,
Chris

Re: ComboBox - need to get different values on select than displayed

by sos :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Have a look here -
http://shaneosullivan.wordpress.com/2006/07/30/getting-the-selected-id-from-a-dojo-combobox/

It was written for 0.4.x, but may still be valid for version 1.x

Shane

On 28/01/2008, theKryz <Treschklingen@...> wrote:

>
> Hi,
>
> I am using the Dojo ComboBox for convenience - because it looks better than
> the normal ComboBox (fits to text width).
>
> However, when building my ComboBox Content, I realized, that the
> "onChange"-Javascript-Function is called with only the parameter: the
> content text of the selected <option>-tag. I need to set another value to
> one tag, that is given to the function though.
>
> --> One that is displayed and one that is passed to the function, but
> otherwise hidden.
>
> How can I do this?
> I bet there's a really simple solution.
>
> Thanks for any help,
> Chris
> --
> View this message in context: http://www.nabble.com/ComboBox---need-to-get-different-values-on-select-than-displayed-tp15136741p15136741.html
> Sent from the Dojo mailing list archive at Nabble.com.
>
> _______________________________________________
> FAQ: http://dojotoolkit.org/support/faq
> Book: http://dojotoolkit.org/docs/book
> Forums: http://dojotoolkit.org/forum
> Dojo-interest@...
> http://dojotoolkit.org/mailman/listinfo/dojo-interest
>
_______________________________________________
FAQ: http://dojotoolkit.org/support/faq
Book: http://dojotoolkit.org/docs/book
Forums: http://dojotoolkit.org/forum
Dojo-interest@...
http://dojotoolkit.org/mailman/listinfo/dojo-interest

Re: ComboBox - need to get different values on select than displayed

by Vikas Sasidharan :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

It seems you need a widget that looks and works like ComboBox but works internally like the HTML Select, i.e. supporting options having hidden value and a displayed label. If this is really the case, have a look at the FilteringSelect widget. It brings in some (at times) unnecessary luggage with it (such as validation, forcing an option etc.), but that's not that bad.

While we are at it, does anyone have any idea why Dojo doesn't have an exact equivalent of the HTML Select? The dijit ComboBox doesn't add up because it doesn't support hidden values and the FilteringSelect,well, forces too many extra things such as validation. In other words, why don't we have a dijit.form.Select?

Rgds,
Vikas

On Mon, 2008-01-28 at 07:17 -0800, theKryz wrote:
Hi,

I am using the Dojo ComboBox for convenience - because it looks better than
the normal ComboBox (fits to text width).

However, when building my ComboBox Content, I realized, that the
"onChange"-Javascript-Function is called with only the parameter: the
content text of the selected <option>-tag. I need to set another value to
one tag, that is given to the function though.

--> One that is displayed and one that is passed to the function, but
otherwise hidden.

How can I do this?
I bet there's a really simple solution.

Thanks for any help,
Chris
Any comments or statements made in this email are not necessarily those of Tavant Technologies.
The information transmitted is intended only for the person or entity to which it is addressed and may 
contain confidential and/or privileged material. If you have received this in error, please contact the 
sender and delete the material from any computer. All e-mails sent from or to Tavant Technologies 
may be subject to our monitoring procedures.

_______________________________________________
FAQ: http://dojotoolkit.org/support/faq
Book: http://dojotoolkit.org/docs/book
Forums: http://dojotoolkit.org/forum
Dojo-interest@...
http://dojotoolkit.org/mailman/listinfo/dojo-interest

Re: ComboBox - need to get different values on select than displayed

by G. Sharon Yang :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Did anybody solve this issue?
I tried this method and still didn't get the value/id/name for each option:

<label for='class'><Class></label><br>
<select dojoType="dijit.form.ComboBox"
                autocomplete="true"
                hasDownArrow="true"
                id='filter1'
                onChange="doFilter(this)"
>
<option userID="option1">Sub-filter-1</option>
<option userID="option2">Sub-filter-2</option>
<option userID="option3">Sub-filter-3</option>


var lastFilterValue = "";
                function doFilter(el) {
                        console.log("value:"+el.value);
                        console.log("select id:"+el.id);
                        console.log("selected option id:"+el.userID);
                        if (el.value!=lastFilterValue) {
                                lastFilterValue = el.value;
                                grid3.filter({name:el.value});
                        }
                }


What I need to get is "option1", "option2" for each option, instead of
the select id "filter1", which is el.id.  el.value always returns the
displayed value for each option.

Thanks,

Sharon

On Mon, Jan 28, 2008 at 8:26 AM, Shane
O'Sullivan<shaneosullivan1@...> wrote:

> Have a look here -
> http://shaneosullivan.wordpress.com/2006/07/30/getting-the-selected-id-from-a-dojo-combobox/
>
> It was written for 0.4.x, but may still be valid for version 1.x
>
> Shane
>
> On 28/01/2008, theKryz <Treschklingen@...> wrote:
>>
>> Hi,
>>
>> I am using the Dojo ComboBox for convenience - because it looks better than
>> the normal ComboBox (fits to text width).
>>
>> However, when building my ComboBox Content, I realized, that the
>> "onChange"-Javascript-Function is called with only the parameter: the
>> content text of the selected <option>-tag. I need to set another value to
>> one tag, that is given to the function though.
>>
>> --> One that is displayed and one that is passed to the function, but
>> otherwise hidden.
>>
>> How can I do this?
>> I bet there's a really simple solution.
>>
>> Thanks for any help,
>> Chris
>> --
>> View this message in context: http://www.nabble.com/ComboBox---need-to-get-different-values-on-select-than-displayed-tp15136741p15136741.html
>> Sent from the Dojo mailing list archive at Nabble.com.
>>
>> _______________________________________________
>> FAQ: http://dojotoolkit.org/support/faq
>> Book: http://dojotoolkit.org/docs/book
>> Forums: http://dojotoolkit.org/forum
>> Dojo-interest@...
>> http://dojotoolkit.org/mailman/listinfo/dojo-interest
>>
> _______________________________________________
> FAQ: http://dojotoolkit.org/support/faq
> Book: http://dojotoolkit.org/docs/book
> Forums: http://dojotoolkit.org/forum
> Dojo-interest@...
> http://dojotoolkit.org/mailman/listinfo/dojo-interest
>
_______________________________________________
FAQ: http://dojotoolkit.org/support/faq
Book: http://dojotoolkit.org/docs/book
Forums: http://dojotoolkit.org/forum
Dojo-interest@...
http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest

Re: ComboBox - need to get different values on select than displayed

by G. Sharon Yang :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

never mind. I figured it out.

I use FilteringSelect, instead of Combobox. To set value for each option:

<option value="option1">Sub-filter-1</option>
<option value="option2">Sub-filter-2</option>
<option value="option3">Sub-filter-3</option>

Then in javascript, I use:

function doFilter(el) {
                       console.log("value:"+el.value);
..............................

el.value will return your set value, instead of display value.

Hope this will help someone.

Sharon

On Wed, Aug 5, 2009 at 10:59 AM, G. Sharon Yang<okghyang@...> wrote:

> Did anybody solve this issue?
> I tried this method and still didn't get the value/id/name for each option:
>
> <label for='class'><Class></label><br>
> <select dojoType="dijit.form.ComboBox"
>                autocomplete="true"
>                hasDownArrow="true"
>                id='filter1'
>                onChange="doFilter(this)"
>>
> <option userID="option1">Sub-filter-1</option>
> <option userID="option2">Sub-filter-2</option>
> <option userID="option3">Sub-filter-3</option>
>
>
> var lastFilterValue = "";
>                function doFilter(el) {
>                        console.log("value:"+el.value);
>                        console.log("select id:"+el.id);
>                        console.log("selected option id:"+el.userID);
>                        if (el.value!=lastFilterValue) {
>                                lastFilterValue = el.value;
>                                grid3.filter({name:el.value});
>                        }
>                }
>
>
> What I need to get is "option1", "option2" for each option, instead of
> the select id "filter1", which is el.id.  el.value always returns the
> displayed value for each option.
>
> Thanks,
>
> Sharon
>
> On Mon, Jan 28, 2008 at 8:26 AM, Shane
> O'Sullivan<shaneosullivan1@...> wrote:
>> Have a look here -
>> http://shaneosullivan.wordpress.com/2006/07/30/getting-the-selected-id-from-a-dojo-combobox/
>>
>> It was written for 0.4.x, but may still be valid for version 1.x
>>
>> Shane
>>
>> On 28/01/2008, theKryz <Treschklingen@...> wrote:
>>>
>>> Hi,
>>>
>>> I am using the Dojo ComboBox for convenience - because it looks better than
>>> the normal ComboBox (fits to text width).
>>>
>>> However, when building my ComboBox Content, I realized, that the
>>> "onChange"-Javascript-Function is called with only the parameter: the
>>> content text of the selected <option>-tag. I need to set another value to
>>> one tag, that is given to the function though.
>>>
>>> --> One that is displayed and one that is passed to the function, but
>>> otherwise hidden.
>>>
>>> How can I do this?
>>> I bet there's a really simple solution.
>>>
>>> Thanks for any help,
>>> Chris
>>> --
>>> View this message in context: http://www.nabble.com/ComboBox---need-to-get-different-values-on-select-than-displayed-tp15136741p15136741.html
>>> Sent from the Dojo mailing list archive at Nabble.com.
>>>
>>> _______________________________________________
>>> FAQ: http://dojotoolkit.org/support/faq
>>> Book: http://dojotoolkit.org/docs/book
>>> Forums: http://dojotoolkit.org/forum
>>> Dojo-interest@...
>>> http://dojotoolkit.org/mailman/listinfo/dojo-interest
>>>
>> _______________________________________________
>> FAQ: http://dojotoolkit.org/support/faq
>> Book: http://dojotoolkit.org/docs/book
>> Forums: http://dojotoolkit.org/forum
>> Dojo-interest@...
>> http://dojotoolkit.org/mailman/listinfo/dojo-interest
>>
>
_______________________________________________
FAQ: http://dojotoolkit.org/support/faq
Book: http://dojotoolkit.org/docs/book
Forums: http://dojotoolkit.org/forum
Dojo-interest@...
http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest