Results 1 to 14 of 14
  1. #1
    New Lounger
    Join Date
    Apr 2005
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Need to create dynamic dropdown to collect detail (2002)

    Hello,

    Here is my dilemma. I read about dynamic drop downs and am wanting to know if this could be used for what we need to get done.

    I want to collect information about a sales lead and then want to ask them a question as to how many of something they have. Depending on their answer, I want to be able to provide fields in the form for them to insert information.

    Whether the variable is a car, how many pets or children...there will be a couple of areas to fill out that I need to have for each.

    Name
    Address
    Phone

    How many cars do you have? Tell us about them:
    (They indicate 2)

    Car Model
    Car Type
    Number of Doors
    Licence

    Car Model
    Car Type
    Number of Doors
    Licence


    Submit

    ================================

    For now, we will be happy if the form can do that. We then plan to collect info in a csv to import to an access db.

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Need to create dynamic dropdown to collect de

    I would do this by first creating the maximum number of fields that I might want to have the user fill in. For example, 4 cars. This way, my HTML page contains all of the fields in the right places, with the right names, etc. Then, I would hook a JavaScript function up to the drop-down (SELECT) control that would reveal the correct parts of the form. I don't have any examples handy, sorry, but the general approach would be:

    <select id="carnum" size="1" title="Choose the number of cars" onchange="showCarForm('carnum');">
    <option value="1">1 vehicle</option>
    etc.
    </select>
    <div id="carFields1" style="display: hidden">
    Make: <input name="Make1" type="text">
    etc.
    </div>

    <script>
    function showCarForm(carSelect)
    {
    var myList = document.getElementById(carSelect);
    var numToShow = myList.options[myList.selectedIndex].value;
    // Here would be code to open up the correct number of sections
    // e.g., use a for loop counting up to numToShow to "unhide"
    // DIVs with your form info in them... to unhide, change the
    // display property from "hidden" to "block"
    var myDiv = document.getElementById("carFields" + loopCounter);
    myDiv.style.display = "block";
    }
    </script>

    I didn't test that, it's just a snippet that might help. Hope it does.

  3. #3
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Need to create dynamic dropdown to collect de

    I should add: if you don't mind sending the information to the server after asking the initial question, you can return a custom page tailored to the user's initial responses. This is a lot more powerful and might be more convenient, particularly if you have no reason to learn JavaScript and you know some Visual Basic from working on Office macros (ASP usually is written in VBScript). On the other hand, it does mean a bit of waiting around for the user between questions.

  4. #4
    New Lounger
    Join Date
    Apr 2005
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Need to create dynamic dropdown to collect de

    Jscher2000,

    As you mentioned in your 2nd post, I think a single refresh after they indicate the number of items is fine. Could you explain how I would go about passing the information they already entered to a "new" form?

    I am new to creating forms but very familiar with html.
    I also found out yesterday we will be ordering FP2003 upgrade which should arrive next week.

  5. #5
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Need to create dynamic dropdown to collect de

    Microsoft 's ASP (Active Server Pages) technology probably is the easiest server-side solution to learn and to integrate with FrontPage. However, it's somewhat difficult to get started without some relevant examples. If you search this forum and also our Web Development board, you can find sites with samples of ASP solutions for processing form submissions.

  6. #6
    New Lounger
    Join Date
    Apr 2005
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Need to create dynamic dropdown to collect de


  7. #7
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Need to create dynamic dropdown to collect de

    Looks pretty good! Two things:
    1. <LI>There is a typo in the ID of the child2 zip code (says child1zip) which causes a script error. Fixing that should let the loop run to completion and hide the undesired sections if the user changes from, say, 3 to 1.

      <LI>Reloading the page fails to clear the select value on both IE and Firefox. See if adding selected="selected" to the first option tag fixes that (otherwise, it looks very strange because there are no data fields even if the number is 1 or 3).
    Hope this helps. <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

  8. #8
    New Lounger
    Join Date
    Apr 2005
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Need to create dynamic dropdown to collect de

    Jscher2000,

    <img src=/S/bananas.gif border=0 alt=bananas width=33 height=35>
    got those fixed!
    Here is the updated version.
    http://www.eastendimports.com/flu/regtest4.htm

    I am wondering how I populate the fields if person chooses "Yes" to the dropdown:
    "Is the clinic address and contact same as client contact above?:"

    We are trying to save the person time who is entering the info. Basically, the dept decided that the person fillig out the form can say "yes" to the following 2 items.
    ==is the location the same?
    ==is the contact person/info the same?

    I think we will allow them to specify a time for each location.

    I'm learning quickly how to put this together!

  9. #9
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Need to create dynamic dropdown to collect de

    > I am wondering how I populate the fields if person chooses "Yes" to the dropdown
    > "Is the clinic address and contact same as client contact above?"

    Well, I guess the first thing might be to move the question up before the first input field, otherwise someone might not see it (like me).

    You code could assign the contact field information to the first location fields using the same methods you are using to blank them out, just changing the right side to refer to the contact field textboxes. (At least, that seems right in theory, I haven't tried it with your page.)

    By the way, you need to change the ID of your yes/no drop-downs to be unique (right now, they conflict with the address field). Actually, I don't see any reason to have this for the second and third addresses; why would they list three identical locations? Well, maybe it's a different room number or building. I guess I don't know enough about the possible scenarios.

  10. #10
    New Lounger
    Join Date
    Apr 2005
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Need to create dynamic dropdown to collect de

    ah, the ID's need to be different?

    Let me see what I get this afternoon.

  11. #11
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Need to create dynamic dropdown to collect de

    This is hard to read this way. Can you post the page and I can use Firefox's source viewer (nicely color-coded and indented) to view it? (Also, it keeps the thread shorter for those receiving nightly emails of new activity on this board.)

  12. #12
    New Lounger
    Join Date
    Apr 2005
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Need to create dynamic dropdown to collect de

    I am missing something, I can't get the part that would repopulate the additional fields to work. Here is my code:

    ================================================== =======
    so sorry!

    http://www.eastendimports.com/flu/regtest8.htm

  13. #13
    New Lounger
    Join Date
    Apr 2005
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Need to create dynamic dropdown to collect de

    http://www.eastendimports.com/flu/regtest12.htm

    How to say this...

    I cannot pass the information with the checkbox to the newly created drop down items. Error in line grrr.

  14. #14
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Need to create dynamic dropdown to collect de

    I've been traveling. There is a problem with using document.<span style="background-color: #FFFF00; color: #000000; font-weight: bold">getElementById</span hi>("child" + j + "address") when you have not set an ID for the input. There is a getElementByName method, I believe, but I've never used it, so I don't know whether you can just plug it in or not.

Posting Permissions

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