#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    12
    Rep Power
    0

    Dropdown box within dropdown box


    I have a form that contains a dropdown box which when a selection is made, it opens another dropdown box with choices. Within this html page, everything works fine. It uses a function to populate the dropdowns. I am now submitting to a .asp page which sends an email to me using CDONTS. The only problem I have is being able to get the text values for my 2 dropdown boxes, instead I am getting the numerical values associated with them. I don't know what values to use to put in Response.form("?????") for each of the dropdown boxes. Please see www.faxfoodorder.com/newpage2.htm see "Type of Item?" and "Item" dropdown boxes.


    I will now supply the function, some of the code related to the function and dropdown boxes and the .asp page.

    Thanks for the help

    Larry

    FUNCTION:

    function selectChange(control, controlToPopulate, ItemArray, GroupArray)
    {
    var myEle ;
    var x ;

    // Empty the second drop down box of any choices
    for (var q=controlToPopulate.options.length;q>=0;q--) controlToPopulate.options[q]=null;

    // ADD Default Choice - in case there are no values
    myEle = document.createElement("option") ;
    myEle.value = 0 ;
    myEle.text = "[SELECT]" ;
    controlToPopulate.add(myEle) ;
    // Now loop through the array of individual items
    // Any containing the same child id are added to
    // the second dropdown box
    for ( x = 0 ; x < ItemArray.length ; x++ )
    {
    if ( GroupArray[x] == control.value )
    {
    myEle = document.createElement("option") ;
    myEle.value = x ;
    myEle.text = ItemArray[x] ;
    controlToPopulate.add(myEle) ;
    }
    }
    }
    // End -->

    </script>
    _________________________________________________
    var arrItems1 = new Array();
    var arrItemsGrp1 = new Array();

    arrItems1[63] = "Chopped Liver 9.99";
    arrItemsGrp1[63] = 1;
    arrItems1[64] = "Stuffed Derma with gravy 9.99";
    arrItemsGrp1[64] = 1;
    arrItems1[65] = "Stuffed Cabbage with sweet & sour sauce 9.99";
    arrItemsGrp1[65] = 1;
    arrItems1[66] = "Fried Kreplach with Onions 9.99";
    arrItemsGrp1[66] = 1;
    arrItems1[67] = "Chicken Fricassee 9.99";
    arrItemsGrp1[67] = 1;
    arrItems1[68] = "Tongue Polynaise with Sweet & Sour Sauce 9.99";
    arrItemsGrp1[68] = 1;
    arrItems1[69] = "Potted Meatballs with Gravy 9.99";
    arrItemsGrp1[69] = 1;
    arrItems1[70] = "Pickled Herring with Onions & Parve Cream Sauce 9.99";
    arrItemsGrp1[70] = 1;
    arrItems1[71] = "Gefilte Fish with Horseradish 9.99";
    arrItemsGrp1[71] = 1;
    arrItems1[72] = "Fruit Salad - All fresh Fruits 9.99";
    arrItemsGrp1[72] = 1;
    __________________________________________________
    Notice the Select secondchoice

    <SELECT id=firstChoice name=firstChoice onchange="selectChange(this, secondChoice, arrItems1, arrItemsGrp1);">
    <option value=0 SELECTED>[SELECT]</option>
    <option value=1>Appetizers</option>
    <option value=2>Side Dishes/Misc.</option>
    <option value=3>Homemade Soups</option>
    <option value=4>Eggs & Omelettes</option>
    <option value=5>Hot Open Sand.</option>
    <option value=6>Lox on Bagel</option>
    <option value=7>Beef/Turkey Burgers</option>
    <option value=8>Overstuffed Sand.</option>
    <option value=9>Combination Sand.</option>
    <option value=10>Deli Platters</option>
    <option value=11>Entrees</option>
    <option value=12>Cold Salad Platters</option>
    <option value=13>Kids Menu</option>
    <option value=14>Desserts</option>
    <option value=15>Beverages</option>
    </SELECT>
    </TD><TD>
    <SELECT id=secondChoice name=secondChoice>
    </Select>
    ____________________________________________________
    ASP page from the Submit from Newpage2.htm - please note the following in the code: THE NEXT 2 STATEMENTS BELOW ARE THE PROBLEM ***************

    Here is the code:


    <%LANGUAGE="vbScript"%>
    <%
    Dim t1name,t1,t2name,t2,t3name,t3,femail,emailfrom,emailto,subj,mybody, dashline
    Dim hemail, haddressdeliv, litaddressdeliv, litfirstchoice, litaddtlcomments
    Dim hfirstchoice, hsecondchoice, litsecondchoice, haddtlcomments, hconame, litconame
    Dim blankline
    emailfrom = Request.Form("emailaddress")
    emailto = "info@faxfoodorder.com"
    acttime = request.form("time")
    hpudeliv = request.form("pudeliv")
    hconame = request.form("coname")
    litconame = "Company: "
    litpudeliv = "Pickup or Delivery: "
    litqty = "Quantity: "
    dashline = "___________________________________"
    blankline = " "
    hquantity = request.form("quantity")
    litaddtlcomments = "Special requests: "
    haddtlcomments = request.form("addtlcomments")
    %>
    <!-- THE NEXT 2 STATEMENTS BELOW ARE THE PROBLEM *************** -->
    <% hfirstchoice = request.form("firstchoice")
    hsecondchoice = request.form("secondchoice") %>
    <%
    litfirstchoice = "Type of Item: "
    litsecondchoice = "Item: "
    hemail = "Email: "
    htime = "Time: "
    haddressdeliv = request.form("addressdeliv")
    litaddressdeliv = "Address: "
    subj = "My Order"
    t1 = request.form("name")
    t1name = "Name: "
    t2 = Request.Form("emailaddress")
    t2name = "Email: "
    t3 = request.form("phone")
    t3name = "Phone: "

    Dim ObjMail
    Set ObjMail = Server.CreateObject("CDONTS.NewMail")
    ObjMail.To = emailto
    'in the next line you can change that email address to something else
    'like "myform@myurl.com", just be sure and put it between quotes " "
    ObjMail.From = emailfrom
    'you can also change "Form Submission" to something else like "form results" etc.
    ObjMail.Subject = subj

    ObjMail.Body = t1name &_
    t1 & vbcrlf &_
    t2name & t2 & vbcrlf &_
    t3name & t3 & vbcrlf &_
    litpudeliv & hpudeliv & vbcrlf &_
    htime & acttime & vbcrlf &_
    litaddressdeliv & haddressdeliv & vbcrlf &_
    litconame & hconame & vbcrlf &_
    blankline & vbcrlf &_
    litqty & hquantity & vbcrlf &_
    litfirstchoice & hfirstchoice & vbcrlf &_
    litsecondchoice & hsecondchoice & vbcrlf &_
    litaddtlcomments & vbcrlf &_
    haddtlcomments &vbcrlf &_
    dashline
    ObjMail.Send
    Set ObjMail = Nothing
    'HERE you make a choice. You can redirect the user to any page in your site
    Response.Redirect "http://faxfoodorder.com/newpage2.htm"
    'Or just say thanks. Delete the line you dont want. Either above or below
    Response.Write"Thank You"
    %>secondChoice name=secondChoice
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    15
    Rep Power
    0
    well, you're getting number values when you use Response.Form() on the drop down boxes because of this line:

    myEle.value = x ;

    what if you made that:

    myEle.value = ItemArray[x];

    then you'd be setting the value to the same thing as the text for the option... not sure if it'd work smoothly (since i didn't look to closely at the rest of the code), but it might be worth a shot.
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    12
    Rep Power
    0
    By using "myEle.value = ItemArray[x];" , it actually did pickup the proper description for the Item, which is my 2nd dropdown box. That was good. However, for the first dropdown box, I am still getting the numerical value. Any more ideas on how to get it's text value?

    Thanks,

    Larry
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    15
    Rep Power
    0
    to correct the number values for the first choice, just change the values of the following to the text of the options:

    <option value=1>Appetizers</option>
    <option value=2>Side Dishes/Misc.</option>
    <option value=3>Homemade Soups</option>
    <option value=4>Eggs & Omelettes</option>
    <option value=5>Hot Open Sand.</option>
    <option value=6>Lox on Bagel</option>
    <option value=7>Beef/Turkey Burgers</option>
    <option value=8>Overstuffed Sand.</option>
    <option value=9>Combination Sand.</option>
    <option value=10>Deli Platters</option>
    <option value=11>Entrees</option>
    <option value=12>Cold Salad Platters</option>
    <option value=13>Kids Menu</option>
    <option value=14>Desserts</option>
    <option value=15>Beverages</option>

    so instead of:
    <option value=1>Appetizers</option>

    use:
    <option value="Appetizers">Appetizers</option>

    etc.
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    12
    Rep Power
    0
    When I change the values to the actual names as you suggested, the second dropdown box only shows "Selected" and none of the actual selections. Could that be due to this:

    <option value=0 SELECTED>[SELECT]</option>

    Should value=0 be changed?
  10. #6
  11. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    15
    Rep Power
    0
    ahh, i figured out where the problem occurs:

    if ( GroupArray[x] == control.value )

    if that is satisfied, it populates the box. but, since you changed the values of the control that's being selected, it never matches up (GroupArray[x] is a number while control.value is the text strings you just entered for the first choice options. so, as i see that GroupArray[] refers to the last parameter in the function call, it takes the value of arrItemsGrp1 in this instance. and this is where you set the values for arrItemsGrp1:

    arrItems1[63] = "Chopped Liver 9.99";
    arrItemsGrp1[63] = 1;
    arrItems1[64] = "Stuffed Derma with gravy 9.99";
    arrItemsGrp1[64] = 1;
    arrItems1[65] = "Stuffed Cabbage with sweet & sour sauce 9.99";
    arrItemsGrp1[65] = 1;
    arrItems1[66] = "Fried Kreplach with Onions 9.99";
    arrItemsGrp1[66] = 1;
    arrItems1[67] = "Chicken Fricassee 9.99";
    arrItemsGrp1[67] = 1;
    arrItems1[68] = "Tongue Polynaise with Sweet & Sour Sauce 9.99";
    arrItemsGrp1[68] = 1;
    arrItems1[69] = "Potted Meatballs with Gravy 9.99";
    arrItemsGrp1[69] = 1;
    arrItems1[70] = "Pickled Herring with Onions & Parve Cream Sauce 9.99";
    arrItemsGrp1[70] = 1;
    arrItems1[71] = "Gefilte Fish with Horseradish 9.99";
    arrItemsGrp1[71] = 1;
    arrItems1[72] = "Fruit Salad - All fresh Fruits 9.99";
    arrItemsGrp1[72] = 1;

    if you change those 1s into "Appetizers", it should work. in other words, change:

    arrItemsGrp1[63] = 1;

    to:

    arrItemsGrp1[63] = "Appetizers";

    and do that for each arrItemsGrp1[]

    if you still encounter problems and you KNOW the strings match, try first converting both GroupArray[] and control.value to strings, then use the valueOf() function. if you run into more problems, let me know.
  12. #7
  13. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    12
    Rep Power
    0
    After making the changes you suggested, I still get the numeric value.
  14. #8
  15. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    15
    Rep Power
    0
    you still get the numerical value for what? for the submissioN?? does the second drop box fill up now?
  16. #9
  17. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    12
    Rep Power
    0
    After making the changes you suggested, I still get the numeric value.
  18. #10
  19. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    12
    Rep Power
    0
    The secondchoice (2nd dropdown box) is ok, I get the text. The firstchoice(1st dropdown box) still has a numeric value after changing arrItemsGrp1[63] = "Appetizers"; and all the other occurrences.
  20. #11
  21. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    12
    Rep Power
    0
    All the results that I am referring to has to do with the email sent to me!
  22. #12
  23. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    15
    Rep Power
    0
    are you sure that all of the firstchoice option values have been changed?

    from:

    <SELECT id=firstChoice name=firstChoice onchange="selectChange(this, secondChoice, arrItems1, arrItemsGrp1);">
    <option value=0 SELECTED>[SELECT]</option>
    <option value=1>Appetizers</option>

    to:

    <option value="Appetizers">Appetizers</option>

    because that's where it'll draw the firstchoice value from... if you're sure you changed that and you're still getting numbers, re-post your updated code so i can see everything you've got now.
  24. #13
  25. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    12
    Rep Power
    0
    After redoing it, it worked fine for firstchoice and secondchoice. I apparently did something wrong the first time. What's confusing is that I still have:

    <SELECT id=firstChoice name=firstChoice onchange="selectChange(this, secondChoice, arrItems1, arrItemsGrp1);">
    <option value=0 SELECTED>[SELECT]</option>

    I thought that "SELECT id=firstChoice name=firstChoice onchange="selectChange(this, secondChoice, arrItems1, arrItemsGrp1);">
    <option value=0 SELECTED>[SELECT]</option>" would be a problem, but it's not. I have no idea why. It still calls the function onchange.

    Thank you very much for your help. It is people like you that give some of us faith and trust in others You Da Man!

    Larry
  26. #14
  27. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    15
    Rep Power
    0
    you're welcome, man. glad it all works now!

    -jeff

IMN logo majestic logo threadwatch logo seochat tools logo