See if this helps:
http://www.mail-archive.com/[email protected]/msg61657.html
musachy
On 8/31/07, peter_smiley <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> Currently I'm using struts 2.0.9 and am trying to use the autocompleter with
> a JSON key/value pair as the input for the autocompletion list.
> What I would like to do is when a value is selected that the key and value
> are available so that I can insert them in another dropdown select, but
> currently I am only able to access the value but not the key.
> Please see my code below:
>
> <code>
> <script type="text/javascript">
>
> function appendOptionToMultiSelect(selectElementName,
> selectedValue,
> selectedText) {
> var newOption = document.createElement("option");
> newOption.value = selectedValue;
> newOption.text = selectedText;
> newOption.selected = true;
> var selectVar =
> document.getElementById(selectElementName);
> selectVar.options[selectVar.options.length] =
> newOption;
> }
>
> var foo = new function() {
> this.init = function() {
> dojo.event.topic.subscribe("/autocompleteTopic", this,
> userNameSelectCallback);
> }
>
> function userNameSelectCallback(data, type, request) {
>
> if( type == 'valuechanged') {
> if(data != null && data != '' ) {
> dojo.debug(data);
> dojo.debug(type);
> dojo.debug(request);
> // I would like to use the
> key and value and set them in a multi
> select list
> // but I don't know where the
> value is stored, or even if it is stored
> at all
>
> appendOptionToMultiSelect('selectedUserIds_Id', ??value??, data);
> // Then would like to reset
> the selectedUserIds_Id combobox to nothing
> // how would I do this?
> }
> }
> }
> }
> foo.init();
> </script>
>
> <s:autocompleter name="personNamePrefix"
> id="personNamePrefixId"
> href="../PersonNameAutocompleter.action"
> theme="ajax"
> loadOnTextChange="true"
> loadMinimumCount="3"
> autoComplete="false"
> showDownArrow="true"
> cssStyle="width: 400px;"
> notifyTopics="/autocompleteTopic"
> forceValidOption="true"/>
>
> <select id="selectedUserIds_Id" name="contestUserIds"
> multiple="multiple">
> <option>Contest Participants</option>
> </select>
>
> </code>
>
> Any help would be greatly appreciated.
>
> Cheers
> Peter
> --
> View this message in context:
> http://www.nabble.com/Autocompleter-JSON-key-value-pair-to-update-other-list-tf4359933.html#a12425633
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
--
"Hey you! Would you help me to carry the stone?" Pink Floyd
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]