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 8362313
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:54:41+00:00 2026-06-09T11:54:41+00:00

I have a grails project where I need to select the fields that I

  • 0

I have a grails project where I need to select the fields that I want to delete and when I click ‘delete’ I need a function to delete all selected items:

html code:

<form name="bookForm" action="list" method="post">
    ....
    <g:link controller="book" action="delete">Delete</g:link>
    ....
    ....
    <g:checkBox id="select_all" name="select_all" value="" onclick="selectAll();" />
    ....
    <g:each in="${bookList}" status="i" var="bookInstance">
        <tr class="${(i % 2) == 0 ? 'odd' : 'even'}">
            <td><g:checkBox id="${bookInstance.id}" name="delete_checkbox" value="" /></td>
        </tr>
    </g:each>
    ....
</form>

javascript code:

<script type="text/javascript">
    function selectAll(){//this function is used to check or uncheck all checkboxes
        var select = document.getElementById("select_all");
        var checkboxes = document.forms['bookForm'].elements['delete_checkbox'];
        if (select.checked){
            for (i = 0; i < checkboxes.length; i++) checkboxes[i].checked = true;
        }else{
            for (i = 0; i < checkboxes.length; i++) checkboxes[i].checked = false;
        }
    }//this function works fine
</script>

Problem:

I need the action to check all checkboxes in the list gsp, and if they are checked, take their ids and delete the record by id.

Can i do that either by groovy or javascript?

  • 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-06-09T11:54:42+00:00Added an answer on June 9, 2026 at 11:54 am

    Rewrite your checkbox like:

    <g:checkBox id="delete_checkbox" name="delete_checkbox" value="${bookInstance.id}" />
    

    So, when you submit, you’ll get an array of ids called _delete_checkbox or delete_checkbox inside your params map. To see what you’re getting you can try printing your params inside the action.

    println params
    

    You can get the desired array by using params['nameOfTheAttribute'].
    Once you have the array of ids, iterate over it and delete them all.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a grails project with a class that I can delete no problem
I have a Grails project with pom.xml that is treated as Maven project by
I have a few Java/Maven projects that I want to use in a Grails
I want to display all the project 's tasks in a page, given that
I have been working Quartz framework in my grails project with lib called quartz-all-1.7.3.
I already have an grails web application, And our project need CAS, however I
I have an existing Grails project that I am upgrading to a new version.
I have a Grails project that I created using Groovy/Grails Tool Suite version 3.0.0M3
In my Grails project i need to create a routine so that, in xx
http://www.grails.org/doc/latest/ref/Constraints/validator.html I have a project where I would like users to log in with

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.