Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1898108
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T06:43:35+00:00 2026-05-17T06:43:35+00:00

I have two g:select comboboxes that I want to add to the multiple select

  • 0

I have two g:select comboboxes that I want to add to the multiple select list when clicking an image.

Here is the function in javascript:

function addToList(list,firstOpt, secOpt)
            {
            var y = document.createElement('option');
            y.text = firstOpt + ' - ' + secOpt;
            y.value = firstOpt+'-'+secOpt;
            var elSel = document.getElementById(list);
            try {
            elSel.add(y, null); // standards compliant; doesn't work in IE
            }
            catch(ex) {
            elSel.add(y); // IE only
            }
            }

I think the problem is here in the actual button:

<img src="${resource(dir:'images',file:'arrow.png')}" onclick="addToList('BList','first','second')"/>

when I click it, “first – second” gets added to the list, not the actual value of the g:select boxes. I also tried ${first} and ${second} but had no luck.

Any help is greatly appreciated, thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T06:43:35+00:00Added an answer on May 17, 2026 at 6:43 am

    You don’t have any code in there that retrieves the values of the first and second select lists.

    You would probably need something like this:

    function addToList(destinationList, sourceList1Id, sourceList2Id) {
    
        // your select lists will need ids
        // e.g. <g:select id="listOneId" .../>
    
        var list1 = document.getElementById(sourceList1Id);
        var list2 = document.getElementById(sourceList2Id);
    
        var list1value = list1.options[list1.selectedIndex].value;
        var list2value = list2.options[list2.selectedIndex].value;
    
        // the rest of your addToList() function, replacing 'firstOpt'
        // and 'secondOpt' with 'list1value' and 'list2value' respectively
        // ...
    }
    

    You might then use this with the following selects:

    <!-- sources -->
    <g:select id="fooList" .../>
    <g:select id="barList" .../>
    
    <!-- destination -->
    <g:select id="bazList" .../>
    
    <img ... onclick="addToList('bazList', 'fooList', 'barList');"/>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok, I have two tables that I am joining and doing a select on
I have multiple selects: <select id=one> <option value=1>one</option> <option value=2>two</option> <option value=3>three</option> </select> <select
I have two comboBoxes, one that lists the 7 days of the week and
I have the following two columns: SELECT b.ip_address AS IP ,b.mask AS MASK FROM
I have tried the following two statements: SELECT col FROM db.tbl WHERE col (LIKE
I have two applications written in Java that communicate with each other using XML
I have two arrays of System.Data.DataRow objects which I want to compare. The rows
I have two classes, and want to include a static instance of one class
I have two select's. The values/text of the second one will vary based on
Hi I have two select queries and I wanna merge them into a single

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.