Jump to content

Best way to handle dynamic form data.


JasonLewis

Recommended Posts

This relates to Ajax as well but more-so JavaScript.

 

Let me use an example. I have a tagging system that's using Ajax to auto-suggest tags. The user can then select a tag from the suggested tags or add the tag they want. If they select a tag, is the best way to go about it adding that tag ID to a hidden field as a comma separated list. Or... keep the selected tags in an array and attach an event to the submit handler of the form, then once submitted insert X amount of hidden inputs (where X is the number of tags) so that I'll have an array of selected tags when they submit.

 

In the past when I've done things like this I've just updated a hidden input each time a tag is added/edited, however I'm just wondering if the second approach is possible and if it's better. The only possibility I can think of is that it won't work due to the form already being submitted and thus the inputs aren't actually added to the post data. I am yet to test this.

 

Cheers.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.