looking for a way to dynamically create a set of form fields

Discussion in 'Programming' started by stevemtno, Dec 9, 2011.

  1. #1
    Hi Everyone,

    Like the subject says, I'm looking for a way to dynamically create a set of form fields. Here is the scenario:

    I'm going to have a customer information form, with company information (business name, address, phone, etc). If the company has more than one location, I need to be able to click a "New Location" button and create a new set of fields for that location. I'm not sure how many times I'll need to create a new set of fields, but at least once or twice, I'm sure.

    I will also need to be able to send the form data to either an email address or a database of some kind. I have a PHP script that I use to send form data to an email address, but nothing to send the data to a database. For now, the email script should be fine. Still I need to be able to send the dynamically created field data. Not sure how to do that. The PHP script I'm currently using specifies the field names. Unless I would just add code based on what the new field names would be (I would think a more dynamic approach to this would be better tho).

    Any advice on which direction to go with all this would be greatly appreciated.

    Thanks!

    Steve
     
    stevemtno, Dec 9, 2011 IP
  2. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #2
    Put 3 (or more) sets of fields in hidden divs. As the user clicks "more", unhide the next div. Send all the fields to the server and parse out whether the field is filled or blank at the server. Email the non-blank fields.

    Saving the data in a database is trivial once it's on the server. Open a connection to the database and use INSERT statements to add the data.
     
    Rukbat, Dec 10, 2011 IP
  3. Deltahost

    Deltahost Well-Known Member

    Messages:
    43
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    108
    #3
    I've heard about "Sonet 3.0"
    May be it will help you
     
    Deltahost, Dec 10, 2011 IP
  4. stevemtno

    stevemtno Guest

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thanks for the reply, Rukbat. This sounds like pretty much what I was thinking, but I don't know how to make it work. Could you point me to, or send me, some example code?

    Thanks for your help!

    Steve
     
    stevemtno, Dec 12, 2011 IP