PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Dynamic Input Names and Id's

  1. ckemp23
    Member

    Hi all,

    I'm going to do my best to describe what I'm attempting to do, and what I've done, but, please let me know if you need more information to provide help.

    What I'm trying to do is create an html table that has 5 columns and any number of rows. It's a very basic order form that will list literature that we have for sale. The first 4 columns provide information about the item, and the 5th column is a simply text input "qty" field that allows a user to enter the "qty" of the item they wish to purchase. You can see what this looks like here: http://web.go-spi.com/cgl/literature/.

    It's important to note that the table is generated dynamically, via a custom loop that I've created in Wordpress. I did it this way to allow us to dynamically add or remove literature items from the table.

    The code:
    http://pastebin.com/dwH52Tf9

    The problem:

    1) I'm not sure how to dynamically set the input name and id so that they are sequential as you go down the form. Currently, as the code is set up, I'll only receive the submitted value of the first input no matter how many inputs are filled in.

    I appreciate any help you can provide. Thanks!

    Posted 12 years ago on Friday October 12, 2012 | Permalink
  2. It looks like you took the static output of a Gravity Form and then included the rendered HTML in your function to create the table? Is that correct? All the code here http://pastebin.com/dwH52Tf9 is included in a page somehow?

    Gravity Forms is not designed to be used like this. You could do something like this by pre-populating your Gravity Form with data pulled from your database, using the gform_pre_render filter, but you can't dynamically add items to a form using code the way you've done it here. The form will not work properly or record entries properly. It seems to me you've used the wrong approach.

    Posted 12 years ago on Friday October 12, 2012 | Permalink
  3. ckemp23
    Member

    Chris,

    Thanks for your quick response. I appreciate it.
    It does make sense now that my approach was futile.

    Thanks!

    Posted 12 years ago on Friday October 12, 2012 | Permalink
  4. If you need help with your next approach please let us know. Looks like you have the skills to pull it off no matter which approach you take.

    Posted 12 years ago on Friday October 12, 2012 | Permalink
  5. ckemp23
    Member

    Will do. Thanks, Chris.

    Posted 12 years ago on Saturday October 13, 2012 | Permalink