Results 1 to 3 of 3

Thread: How do you manage dynamic SECTIONs of a form?

  1. #1
    Join Date
    Dec 2005

    How do you manage dynamic SECTIONs of a form?

    I have a form that is pretty basic...


    However, it also has a section that is pulled by a DB depending on the answer to a selection statement...

    Sponsor Name:

    Select drop-down which when selected reloads the page with a url variable, which is then slapped against the DB to recall the rest of the fields...

    Sponsor Phone:
    Sponsor Email:
    Sponsor Address:

    OK so that is a basic rundown, now here lies the problem, by using JavaScript to reload the page with the sponsor id, none of the other fields are ever committed to a form submit, so they can't be passed, furthermore I can't pass the info in the URL because the info isn't committed to a variable either.

    I know its broad strokes but the code isn't my issue, its the tools at my disposal. Is there a way outside of 2.0 technology to hit a database and populate fields on an already loaded page?

  2. #2
    Join Date
    Dec 2005
    I sucked it up and did it in AJAX. I just have a feeling there is something I'm missing here though that would have solved this. Feel free to still offer suggestions, I'm not in love with my solution.

  3. #3
    Join Date
    Aug 2004
    Another option would be to do it completely with JavaScript on the client side, doing the database query as part of the original form page creation, then passing the results into a JavaScript array (probably a 2-dimension array with the first dimension being the sponsor and the 2nd the sponsor-related values) that a JavaScript function could then reference to populate the field(s) affected by the selected value of the sponsor field.

    This will probably give faster response when the user selects a sponsor, but if there are a lot of sponsor it may have a noticeable effect on the original page load time if the resulting array is really large.
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center