Numbering Gravity Forms List Field Rows

Download a quick bit of code to automatically add numbers to your List field rows in Gravity Forms.

May 16, 2023: Improved styling and removed support for versions less than GF 2.5.

Here’s a quick bit of CSS that will automatically number your Gravity Forms List field rows. It does this using CSS psuedo elements within each row to add a “number” column.

Getting Started

To install this snippet, copy and paste the CSS code to your theme’s style.css file. Then on any List field for which you would like to number the rows, just add the gw-number-rows class to the field’s “CSS Class Name” setting.

Notes

This will work in all modern browsers and IE9+. Depending on your site’s styles, you may need to adjust the margin and width set in the CSS snippet. Experiment!

Automate working with lists!

Gravity Forms Auto List Field auto-syncs the number of rows in a List field with a Number or Quantity field value. It can also count the number of List field rows and use that value in Gravity Forms List field calculations!

For example, selling tickets to an event? As you input the number of people attending, corresponding List field rows will automatically appear on your form as the number of people entered increases, allowing you to easily add ticket holders’ names and emails.

Was this helpful?

If this helped you, let us know in comments! If you use this in the wild, share a link so we can see what you’ve done with it.

Comments

  1. Aaron Riddle
    Aaron Riddle September 9, 2024 at 6:34 pm

    Hi! Is there a way to add a period “.” after the row list number? So it would appear as:

    1. (list field)
    2. (list field)

    Thank you for this!

    Reply
    1. Aaron Riddle
      Aaron Riddle September 9, 2024 at 6:35 pm

      Weird…this comment box unformatted my example. Just want to list the numbers before the row list as “1.” , “2.” , “3.” (etc) with the period added after the number. Thanks!

    1. Dario Space
      Dario Space May 31, 2022 at 12:47 pm

      Hi Somrat,

      It seems to be working as expected when adding the CSS code and the class to the List field. If you have an active Gravity Perks Pro License you can get in touch with us via our support form, so we can assist you further.

      Best,

  2. John
    John January 5, 2022 at 7:22 am

    Hi David

    Thanks for this useful CSS.

    I have it working on 2.5 i.e it displays correctly in a browser but the row numbers do not get written to the entry in the database. Is it supposed to work this way or is there a way to add the row number to the entry for extracting and Gravity PDF reporting purposes?

    Kind regards

    John

    Reply
    1. Samuel Bassah
      Samuel Bassah Staff January 5, 2022 at 7:35 am

      Hi John,

      Yes, that’s how it’s supposed to work. This is a custom CSS, so it numbers the rows in the browser.

      Best,

  3. Robert Thomson
    Robert Thomson May 11, 2021 at 3:20 am

    David, this is great stuff! Already using your snippet for adding rows to a list based on a previous field number.

    Just wondering – is this list numbering snipped still working for the latest version of Gravity Forms? I’m new to Gravity Forms (i.e., like last week), and it seems they’re no longer using tables?

    At the very least, the snippet isn’t working for me on my form:

    Smartphone: https://snipboard.io/ZlVB23.jpg Desktop: https://snipboard.io/8qU0T4.jpg

    Reply
    1. Samuel Bassah
      Samuel Bassah Staff May 11, 2021 at 8:06 am

      Hi Robert,

      You’re right, with the new changes, the custom CSS code doesn’t work with Gravity Forms 2.5. I’ll pass this over to our developers. That said, as a workaround, you can “Enable Legacy Markup” under the form settings, to get the CSS code working again.

      Best,

  4. Antoine Parmentier
    Antoine Parmentier March 11, 2021 at 9:33 am

    Hi David,

    Is there any easy solution to add a “label” to the numbering ? Like “Flight 1, Flight 2, Flight 3, Flight 4, etc” Many thanks in advance

    Reply
    1. Scott Ryer
      Scott Ryer Staff March 11, 2021 at 10:02 am

      Hi Antoine,

      You can add it in front of the counter in the content.

      .gw-number-rows .gfield_list tbody tr:before { content: 'Flight ' counter(gflistrowcounter); counter-increment: gflistrowcounter; }

      You’ll probably also want to adjust the width to accommodate for the extra text.

    1. David Smith
      David Smith Staff July 13, 2018 at 11:32 pm

      Unlikely. You would probably need to include the styles in the PDF generator (assuming it provides a setting for custom CSS).

  5. alper karaman
    alper karaman November 13, 2017 at 10:43 am

    Hello David, is there any way numbering the entries in gravity view like 1. David (first approved entry) 2. Alper (second) 3. …. (third) 4. ….

    Reply
    1. David Smith
      David Smith Staff November 13, 2017 at 11:51 am

      Hi Alper, this solution does not apply to Gravity View. I’d ping their support to see if there’s an existing solution.

  6. Andy Daum
    Andy Daum April 7, 2016 at 3:07 am

    Dear David,

    Thank you so much for all the material you create.

    I’m having a small issue with this snippet. Namely, I can’t get the numbers to increase sequentially. It’s just 1,1,1,1,1,1.

    I thought might be to do with the fact I have this plugin https://wordpress.org/plugins/gravity-forms-list-field-select-drop-down/ installed and was using in the relevant list field. However, I removed the dropdown, deactivated the plugin, and got the same result.

    I’ve put images of all this in this public Doc: https://docs.google.com/document/d/10f25t9NHRMq5pgawN_u9iOfX0hCkh0UXKOnefDCVCns/pub

    I hope I’ve not made any silly errors here, and apologies if so. I would really appreciate your advice!

    Thank you very much. Best, A.

    Reply
  7. Lars
    Lars April 7, 2015 at 4:23 pm

    Hi David,

    Would it be possible to have a list field with two columns and then populate the first column with numbers same way as the above snippet does, but inside the input field instead?

    I’m new to GF and what a great ressource this site is!

    Reply
    1. David Smith
      David Smith Staff April 7, 2015 at 7:41 pm

      Hi Lars, glad you’re finding the site useful. Unfortunately, I don’t have a ready solution for populating the number into one of the columns of the List field.

    2. Lars
      Lars April 8, 2015 at 2:48 am

      Hi David,

      Thanks for the prompt response. I actually thought that it was a pretty simple thing to do using “dynamic population” one way or the other, and that the solution above was of the more advanced type.

      As an alternative, using the above solution, are the numbers for each row then included in any submission of the form?

    3. David Smith
      David Smith Staff April 8, 2015 at 7:25 am

      Hi Lars, it is possible to dynamically populate the List field inputs. If you ping Gravity Forms Support they’ll be able to provide instructions on how you might do that.

      The issue, I suspect, is that when you dynamically populate a List field, it adds the rows automatically. If you want the number to be dynamically generated when a new list field is added, dynamic population probably won’t work.

  8. Adlan Khalidi
    Adlan Khalidi March 10, 2015 at 11:34 pm

    Hi. I’m doing a list of item using Gravity Form.

    In the end of the list or after the list, I want to display the number of rows that user has created.

    E.g. – item A – item B – item C – –

    (the last 2 has no item, so don’t need to calculate)

    Total number :[ 3 ] <- a text field with specific class but user cannot change/disabled)

    Do you know how I can achieve this?

    Thanks

    Reply
  9. Catharine
    Catharine February 26, 2015 at 11:01 am

    Thanks for the link David! Do you still do commissions for features? If so, I was wondering how much you would quote for the list field conditional logic thing.

    Regards, Catharine

    Reply
    1. Catharine
      Catharine March 12, 2015 at 6:05 am

      Hi David,

      I sent you a reply to your email on the 26 Feb, at 16:37 – just assumed you were catching up on a backlog or something! Let me know if you can’t find it and I’ll resend it.

      Thanks, Catharine

    2. David Smith
      David Smith Staff March 12, 2015 at 9:32 am

      Hi Catharine, yeah, not seeing your reply. I just replied again in the same thread. If you’d like to reply again and confirm here, I’ll make sure I got it.

  10. Catharine
    Catharine February 25, 2015 at 12:35 pm

    Hi David,

    Cool snippet! As an aside though, how did you configure that list field so that only the first two columns were required? And also, I understand that at present, you can’t use the inputs within a list field in conditional logic for other fields. Do you have or are you planning to bring out a perk to get around this?

    Thanks, Catharine

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Trouble installing this snippet? See our troubleshooting tips.
  • Need to include code? Create a gist and link to it in your comment.
  • Reporting a bug? Provide a URL where this issue can be recreated.

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.

Download Snippet

Numbering Gravity Forms List Field Rows

This field is for validation purposes and should be left unchanged.