Generate New Form Elements Dynamically

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MitchellEr
    New Member
    • Mar 2008
    • 6

    Generate New Form Elements Dynamically

    Hi,

    I am in the process of creating several forms where a group of elements on the form need to be created dynamically.

    For example, in the case of one of the forms, I have a drop down for school, a text box for degree, and a text box for concentration. The form shows 3 of these groupings by default but would like the user to be able to "add more" 3 element groupings if need be and "remove" the additional elements if needed.
    The schools drop down is actually a list generated from a database table (using classic ASP).

    I see several examples of doing this with static content on the web using Javascript/CSS but not clear on how to incorporate the database piece with it so the dropdown options can be generated from the database table and also the cleanest way to create the new form elements dynamically from the various examples.

    If anyone has any suggestions, it would be great!

    Thank you!
  • iam_clint
    Recognized Expert Top Contributor
    • Jul 2006
    • 1207

    #2
    The best way to make it dynamic with the database fields is to make an ajax query to a serverside page (aka your asp classic). you can have it write to the page delimited by commas or something whatever you want then split it in the javascript and use dom to create/remove children and elements. There are examples of ajax on this site.. If you cannot figure this out post a reply.

    Comment

    • MitchellEr
      New Member
      • Mar 2008
      • 6

      #3
      Hi,

      I'm completely new to Ajax so not 100% sure how to do this.
      Can you please point me to an example of this if there is one?

      Thanks so much!


      Originally posted by iam_clint
      The best way to make it dynamic with the database fields is to make an ajax query to a serverside page (aka your asp classic). you can have it write to the page delimited by commas or something whatever you want then split it in the javascript and use dom to create/remove children and elements. There are examples of ajax on this site.. If you cannot figure this out post a reply.

      Comment

      • mmurph211
        New Member
        • Jan 2008
        • 13

        #4
        This should give you a start:
        http://www.matts411.co m/webdev/creating_form_e lements_with_ja vascript

        Comment

        Working...