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

  • Home
  • SEARCH
  • 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 6931399
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:34:20+00:00 2026-05-27T11:34:20+00:00

I have a dynamically displayed lists, by selecting item in the first list, the

  • 0

I have a dynamically displayed lists, by selecting item in the first list, the items in the second list would be populated(using ajax).

The code :

            <g:each in="${files}" var="file" status="i">
                <tr>
                    <td>
                        <%
                            String name = file.fileName;
                            if (name.length() > 30) {
                                def result = "";
                                int z = 0;
                                name.each { character ->
                                    result = "${result}${character}";
                                    z++;
                                    if (z > 30) {
                                        z=0;
                                        result = "${result}<br />";
                                    }
                                }

                                println result;
                            } else {
                                println name;
                            }
                        %>
                        <g:hiddenField name="files.${i}" value="${file.fileName}" />
                    </td>
                    <td>
                        <g:select name="manufacturers.${i}" from="${manufacturers}" onChange="updateDevices('${i}')"  noSelection="${['null':'Select a manufacturer']}" value="${fileInfo[file.fileName]?.selectedManufacturer}" />
                    </td>
                    <td>
                        <div id="devicesField.${i}">
                            <g:if test="${fileInfo[file.fileName]?.selectedDevice != null}">
                                <g:select name="devices.${i}" class="deviceSelect" from="${fileInfo[file.fileName]?.devices}" noSelection="${['null':'Select a manufacturer']}" value="${fileInfo[file.fileName]?.selectedDevice?.toString()}" />
                            </g:if>
                            <g:else>
                                <g:select name="devices.${i}" class="deviceSelect" from="${[:]}" noSelection="${['null':'Select a manufacturer']}" />
                            </g:else>
                        </div>
                    </td>
                    <td><input type="button" value="Add a Device" onClick="deviceInfo('${i}','fileInfo','files','manufacturers')" /></td>
                </tr>

                <br />
            <div id="deviceInfo.${i}">

            </div>
            </g:each>
            </table>


            <br />
            Can't find your device? <a href="mailto:support@flexion.se?subject=Wizard%20New%20Device">Request new device addition</a>
            <br /><br />
            <g:submitButton name="back" value="Back" />&nbsp;<g:submitButton name="next" value="Next" />
            <g:hiddenField name="viewAccordingToBrowser" value="${currentView}" />
        </g:form>
    </div>
</div>


<script>
function updateDevices(id) {
    new Ajax.Updater(
            "devicesField." + id,
            "/wizard/submission/ajaxGetDevicesForManufacturer", {
                method:'get',
                parameters: {
                    selectedValue : $F("manufacturers." + id),
                    id: id
                }
            }
        );
}

function deviceInfo(id,fileInfo,files,manufacturers) {
alert("hi, in deviceInfo function .... ");

new Ajax.Updater(
            "deviceInfo." + id,
            "/wizard/submission/ajaxGetDevicesInfo", {
                method:'get',
                parameters: {
                    fileInfo : fileInfo,
                    files: files,
                    manufacturers : manufacturers,
                    id: id
                }
            }
        );

}
</script>
</body>
</html>

I would like to have a button next to the list boxes and upon clicking it I want to add another set of list boxes below.

I tried onclick event of the button, but itseems to be not working properly.

Any better ideas would be helpful.

—-the controller code for the ajax method is

def ajaxGetDevicesInfo = {
        LOG.debug("inside ajaxGetDevicesInfo %%%%%%%%%%%%%%%%%")
        LOG.debug("fileInfo=" + params.fileInfo);
        LOG.debug("files=" + params.files);
        LOG.debug("manufacturers=" + params.manufacturers);
        LOG.debug("id=" + params.id);
            render(template:"deviceInfo", model : ['fileInfo' : params.fileInfo, 'files': params.files, 'manufacturere': params.manufacturers])

    }

the template for the dynamic ajax view is

<table>
<g:each in="${files}" var="file" status="i">
<g:hiddenField name="files.${i}" value="${file.fileName}" />
<tr>
<td></td>
<td>
   <g:select name="manufacturers.${i}" from="${manufacturers}" onChange="updateDevices('${i}')"  noSelection="${['null':'Select a manufacturer']}" value="${fileInfo[file.fileName]?.selectedManufacturer}" />
</td>
<td>
    <g:if test="${fileInfo[file.fileName]?.selectedDevice != null}">
        <g:select name="devices.${i}" class="deviceSelect" from="${fileInfo[file.fileName]?.devices}" noSelection="${['null':'Select a manufacturer']}" value="${fileInfo[file.fileName]?.selectedDevice?.toString()}" />
    </g:if>
    <g:else>
        <g:select name="devices.${i}" class="deviceSelect" from="${[:]}" noSelection="${['null':'Select a manufacturer']}" />
    </g:else>
</td>
</tr>
</g:each>
</table>

its not working as intended. any input is of great help

  • 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-27T11:34:21+00:00Added an answer on May 27, 2026 at 11:34 am

    I could resolve the issue by including div and implementing ajax.(here is the code)

    <td><input type="button" value="Add a Device" onClick="deviceInfo('${i}')" /></td>
    
    function deviceInfo(id) {
    alert("hi, in deviceInfo function .... ");
    new Ajax.Updater(
                "deviceInfo." + id,
                "/wizard/submission/ajaxGetDevicesInfo", {
                    method:'get',
                    parameters: {
                        selectedValue : $F("manufacturers." + id),
                        id: id
                    }
                }
            );
    
    }
    

    controller method

    def ajaxGetDevicesInfo = {

        Submission submission = (Submission) session[getSessionObjectName()];
        OperatingSystem os = OperatingSystem.get(submission.getOperatingSystemId());
        def manufacturers = terminalService.getAllDeviceManufacturersForType(os.getType());
        terminalService.getDevicesForManufacturerAndType(params.selectedValue, type);
        render(template:"deviceInfo", model : ['id': params.id, 'manufacturers': manufacturers])
    
    }
    

    template to implement div

    <g:select name="manufacturers.${id}" from="${manufacturers}" onChange="updateDevices('${id}')"  noSelection="${['null':'Select a manufacturer']}" value="" />
    </td>
    <td>
    <g:select from="${devices}" name="devices.${id}" value="" noSelection="${['null':'Select Devices']}" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code $(.delete2).click(function() { $('#load2').fadeIn(); } I have dynamically added item via
I have a list of items. For each item there are sublists. It is
I have a large nested list that I am trying to animate using jquery
I have an asp.net Dropdownlist with autopostback enabled. It is not populated dynamically, its
Hi all i have a listbox MainListBox where i add items to dynamically. Now
I have a page that contains dynamically generated Dropdown List controls and I want
I have a ListPreference which I populate dynamically when clicking on the list to
I am trying to insert list items dynamically into the list view. As list
i'm using the source code for multiple selection Dropdown check-list Since, the example has
Hi I have dynamically added functionality like adding a customer to a customer list

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.