Select help please

Discussion in 'HTML' started by Boyd Reilly, Jan 3, 2004.

  1. Boyd Reilly

    Boyd Reilly Guest

    I'm pretty new to this stuff, so any help is welcome.

    I have a select list as follows:
    <select name= "CHDRUGTYPE">
    <option value="1">Beer</option>
    <option value="2">Wine</option>
    <option value="3">Hard Liquor</option>
    <option value="4">Illegal Drugs</option>
    </select>
    On that same page I have another select list. However, I want this list to
    be refelective of what is chosen in the first list. Thus, if Option1 is
    chosen I want the second list to be:

    <select name= "CHDRUG">
    <option value="1">Becks</option>
    <option value="2">Sam Adams</option>
    </select>

    If Option 2 is chosen I want the second list to be:
    <select name= "CHDRUG">
    <option value="1">Thunderbird</option>
    <option value="2">Mad Dog</option>
    </select>

    I don't know how to change the second list after the first list is chosen.

    As said, I'm pretty new to this stuff, so any help is more than welcome.

    Thanks for the help.

    Boyd
     
    Boyd Reilly, Jan 3, 2004
    #1
    1. Advertising

  2. Boyd Reilly wrote:
    > On that same page I have another select list. However, I want this list to
    > be refelective of what is chosen in the first list.


    Have the second list on a server-generated page which changes it.
     
    Leif K-Brooks, Jan 3, 2004
    #2
    1. Advertising

  3. Boyd Reilly

    Boyd Reilly Guest

    I appreciate the help, Leif, but you are talking over my head here. Keep in
    ming,I need everything to be on the same page. If you could, can you post
    codeof what needs to be done.

    TIA.

    Boyd

    "Leif K-Brooks" <> wrote in message
    news:yYqJb.692$...
    > Boyd Reilly wrote:
    > > On that same page I have another select list. However, I want this list

    to
    > > be refelective of what is chosen in the first list.

    >
    > Have the second list on a server-generated page which changes it.
    >
     
    Boyd Reilly, Jan 3, 2004
    #3
  4. Boyd Reilly wrote:
    > I appreciate the help, Leif, but you are talking over my head here. Keep in
    > ming,I need everything to be on the same page. If you could, can you post
    > codeof what needs to be done.


    In PHP:
    if (empty($_POST['CHDRUGTYPE'])) {
    firstform();
    }
    switch ($_POST['CHDRUGTYPE']) {
    case 1:
    # Display the select list for option 1
    break;
    case 2:
    # Select list for option 2
    break;
    default:
    firstform();
    }
    function firstform() {
    // Display a form with the first select list
    }
     
    Leif K-Brooks, Jan 3, 2004
    #4
  5. Boyd Reilly

    Boyd Reilly Guest

    I appreciate your patience with me. But, when I add that code it
    doesnothing but to add more unwanted tet to the screen. Please try this and
    tell me where I go wrong:

    <select name= "CHDRUGTYPE">
    <option value="1">Beer</option>
    <option value="2">Wine</option>
    <option value="3">Hard Liquor</option>
    <option value="4">Illegal Drugs</option>
    </select>

    <select name= "CHDRUG">
    <option value="1">Becks</option>
    <option value="2">Sam Adams</option>
    </select>


    <select name= "CHDRUG">
    <option value="1">Thunderbird</option>
    <option value="2">Mad Dog</option>
    </select>

    if (empty($_POST['CHDRUGTYPE'])) {firstform()} switch ($_POST['CHDRUGTYPE'])
    {case 1: # Display the select list for option 1 break; case 2: # Select list
    for option 2 break; default: firstform(); } function firstform() {// Display
    a form with the first select list}

    Boyd
    "Leif K-Brooks" <> wrote in message
    news:eRrJb.694$...
    > Boyd Reilly wrote:
    > > I appreciate the help, Leif, but you are talking over my head here.

    Keep in
    > > ming,I need everything to be on the same page. If you could, can you

    post
    > > codeof what needs to be done.

    >
    > In PHP:
    > if (empty($_POST['CHDRUGTYPE'])) {
    > firstform();
    > }
    > switch ($_POST['CHDRUGTYPE']) {
    > case 1:
    > # Display the select list for option 1
    > break;
    > case 2:
    > # Select list for option 2
    > break;
    > default:
    > firstform();
    > }
    > function firstform() {
    > // Display a form with the first select list
    > }
    >
     
    Boyd Reilly, Jan 3, 2004
    #5
  6. "Boyd Reilly" <> wrote in message
    news:3ff64e79$0$6766$...
    > I appreciate your patience with me. But, when I add that code it
    > doesnothing but to add more unwanted tet to the screen.


    Leif's code is the best solution to your problem, but it requires your
    website to run on a server that supports server-side scripting. You get the
    extra text on the screen, because you are putting PHP code into a HTML file.

    If you have got lots of different options that are going into the SELECT
    fields, you might be doing good in learning a bit of PHP in addition to the
    HTML you already know. But if you have only got one or two selection boxes
    with a few entries each, this link might help you to achieve what you want:

    http://www.acmesoffware.com/acme/ExamplesJS/jsExm_CreateSelects.asp

    It is an intro on how to dynamically populate select boxes using javascript.
    All you have to do is copy and paste the code into your HTML document (the
    form code into the <body>, the javascript into the <head>) and make the
    appropriate changes to the entries.

    In order to change the javascript in the link above, all you have to do is
    change the value of the <option> tags to whatever you want. E.g. Beer, Wine,
    Hard Liquor, etc. Then in the javascript, you will notice that there are
    lines that currently say:

    case "Item1" :

    and

    case "Item2" :

    Change those lines to what you wrote into your option values. For example:

    case "Beer" :

    case "Wine" :

    etc.

    Finally, enter the new options you want in your selection box under each of
    the "cases". Currently they have got label A1, label A2, etc.

    If you have difficulties with it, let me know.
     
    Fredo Vincentis, Jan 3, 2004
    #6
  7. Leif K-Brooks, Jan 3, 2004
    #7
  8. "Leif K-Brooks" <> wrote in message
    news:lstJb.700$...
    > Fredo Vincentis wrote:
    > > http://www.acmesoffware.com/acme/ExamplesJS/jsExm_CreateSelects.asp

    >
    > Oh &deity;, not one of those! How on earth am I supposed to fill out
    > your form without JavaScript? Since the OP was using a form, some type
    > of server-side scripting must be available. Use that.


    You seem to forget that it takes a bit to learn server-side scripting. Not
    everybody has got the time or the technical skill to learn ASP or PHP. As I
    said: I agree it's the right solution, but javascript may be the way to go
    for Boyd (depends on what his site is trying to achieve).
     
    Fredo Vincentis, Jan 3, 2004
    #8
  9. Boyd Reilly

    Boyd Reilly Guest

    Fredo:

    Thanks for thehelp. I will give it a shot.

    Boyd

    "Fredo Vincentis" <> wrote in message
    news:bt5lls$cn7$...
    > "Boyd Reilly" <> wrote in message
    > news:3ff64e79$0$6766$...
    > > I appreciate your patience with me. But, when I add that code it
    > > doesnothing but to add more unwanted tet to the screen.

    >
    > Leif's code is the best solution to your problem, but it requires your
    > website to run on a server that supports server-side scripting. You get

    the
    > extra text on the screen, because you are putting PHP code into a HTML

    file.
    >
    > If you have got lots of different options that are going into the SELECT
    > fields, you might be doing good in learning a bit of PHP in addition to

    the
    > HTML you already know. But if you have only got one or two selection boxes
    > with a few entries each, this link might help you to achieve what you

    want:
    >
    > http://www.acmesoffware.com/acme/ExamplesJS/jsExm_CreateSelects.asp
    >
    > It is an intro on how to dynamically populate select boxes using

    javascript.
    > All you have to do is copy and paste the code into your HTML document (the
    > form code into the <body>, the javascript into the <head>) and make the
    > appropriate changes to the entries.
    >
    > In order to change the javascript in the link above, all you have to do is
    > change the value of the <option> tags to whatever you want. E.g. Beer,

    Wine,
    > Hard Liquor, etc. Then in the javascript, you will notice that there are
    > lines that currently say:
    >
    > case "Item1" :
    >
    > and
    >
    > case "Item2" :
    >
    > Change those lines to what you wrote into your option values. For example:
    >
    > case "Beer" :
    >
    > case "Wine" :
    >
    > etc.
    >
    > Finally, enter the new options you want in your selection box under each

    of
    > the "cases". Currently they have got label A1, label A2, etc.
    >
    > If you have difficulties with it, let me know.
    >
    >
     
    Boyd Reilly, Jan 3, 2004
    #9
  10. Fredo Vincentis wrote:

    > You seem to forget that it takes a bit to learn server-side scripting.


    It also takes a bit to learn client-side scripting. One is dependable and
    useful for essential functionality, one is undependable and useful for
    optional extras.

    > Not everybody has got the time or the technical skill to learn ASP or PHP.


    or JavaScript.

    --
    David Dorward <http://dorward.me.uk/>
     
    David Dorward, Jan 3, 2004
    #10
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    4
    Views:
    565
    Chris Uppal
    May 5, 2005
  2. KK
    Replies:
    2
    Views:
    706
    Big Brian
    Oct 14, 2003
  3. MuZZy
    Replies:
    7
    Views:
    1,823
    Mike Hewson
    Jan 7, 2005
  4. mera
    Replies:
    7
    Views:
    1,154
  5. palmiere
    Replies:
    1
    Views:
    466
    Erwin Moller
    Feb 9, 2004
Loading...

Share This Page