SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: Dynamic Forms?

  1. #1
    SitePoint Member
    Join Date
    Nov 2003
    Location
    NJ
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Dynamic Forms?

    Hi All.

    Does anyone know of any good tutorials that show how to piece together a form that changes as you select certain options? Or a decent (read "affordable") commercial form system that does this?

    If you choose one option from a drop-down, the next drop-down changes in context. Or choosing an option from a select list reveals a new set of choices altogether.

    Checkboxes used to hide or show form layers ("Use same information?" Yes being the default, a "No" or check off in the box would reveal a section to add new or different information.

    Similar to the sitepoint order form, but more flexible.

    Then the next part of the problem would be to get all the option data from a MySQL table to populate the form fields in the first place, so you wouldn't have to hard code the whole thing. Or would hard coding it be better/easier?

    Thanks.

    Pete
    Total Hosting - Serving the Internet since 1998
    High-Quality, C-Panel WebHosting for as little as $8.25 p/m
    Free Fantastico - Instantly install any of over 70 OS scripts.
    http://www.TotalHosting.com

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I do this as part of the app sold at contactadministrator.com... there are some areas where I have dropdown boxes that determine what should be listed in the next box. One example is "Select type of user"... they select a type, then the next box shows all users of that type.

    I'm not a JavaScript guru (though I could do the "use same information" thing since it doesn't require any hidden divs or populating lists).. so I did it the programming way. You can easily find the javascript that makes a dropdown box into site navigation.. where selecting an option causes hte browser to move to another URL.. so I have something like this..

    <option value="http://www.mysite.com/index.php?usertype=admin">Administrators</option><option value="http://www.mysite.com/index.php?usertype=rep">Sales Reps</option>

    ...etc.. and the javascript handles sending the browser to the selected type. Then I just have index.php handle outputting the same page but with the 2nd dropdown box next to the user type box containing the list of appropriate users. It's not as fast as a fully javascript method, but for me, it was a lot easier to write and the only secure way to do it.

  3. #3
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  4. #4
    SitePoint Member
    Join Date
    Jan 2004
    Location
    Midland, MI USA
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thumbs up Here's what i Use

    Two great scripts:

    go to http://www.quirksmode.org/
    under the w3c DOM menu, select scripts
    look at Uable forms ( which shows more form fields depending on how you answer selected form fields)
    and also look at Extending forms ( which allows you to add more instances of the same form field(s) )
    I use both of these together in a scheduling form. Works great.


Bookmarks

Posting Permissions

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