www.webdeveloper.com
Results 1 to 3 of 3

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

  1. #1
    Join Date
    Dec 2005
    Posts
    203

    How do you manage dynamic SECTIONs of a form?

    I have a form that is pretty basic...

    Name:
    Phone:
    Address:
    etc.

    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:
    etc

    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
    Posts
    203
    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
    Location
    Ankh-Morpork
    Posts
    19,251
    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.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

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



Recent Articles