List Box value >> display text1,2,3,4,5 etc.

Discussion in 'ASP General' started by Fawke101, Apr 16, 2004.

  1. Fawke101

    Fawke101 Guest

    Hi there,

    I need a page where a user selects a value from a menu/list box, and a
    certain part of a form is dislpayed.
    Ideally (probs the easiest way for me) is to create 1 form with all the text
    boxes etc and then when a user selects a value from the initial list box the
    relative boxes are dislpayed.

    Any help or examples of this much appreciated.
    Can you have subforms of a form? if so how could i disable/enable a sub form
    upon selecting a list box value?

    *********
    <select name="lstType" id="lstType">
    <option selected>Please select the value......</option>
    <option value="val_1">value1</option>
    <option value="val_2">value2</option>
    <option value="val_3">value3</option>
    <option value="val_4">value4</option>
    </select>
    *********

    --
    Thanks in advance

    Fawke

    Please remove ANTI and SPAM
    from my email address before emailing me.

    www.bradflack.com
     
    Fawke101, Apr 16, 2004
    #1
    1. Advertising

  2. Fawke101

    Bob Barrows Guest

    Fawke101 wrote:
    > Hi there,
    >
    > I need a page where a user selects a value from a menu/list box, and a
    > certain part of a form is dislpayed.
    > Ideally (probs the easiest way for me) is to create 1 form with all
    > the text boxes etc and then when a user selects a value from the
    > initial list box the relative boxes are dislpayed.
    >
    > Any help or examples of this much appreciated.
    > Can you have subforms of a form? if so how could i disable/enable a
    > sub form upon selecting a list box value?
    >
    > *********
    > <select name="lstType" id="lstType">
    > <option selected>Please select the value......</option>
    > <option value="val_1">value1</option>
    > <option value="val_2">value2</option>
    > <option value="val_3">value3</option>
    > <option value="val_4">value4</option>
    > </select>
    > *********


    This will require client-side DHTML code, which is off-topic for this group.
    Anything that requires something to happen in response to a user's action
    without submitting anything back to the server is outside the purview of
    ASP. In the future, look for groups with "dhtml" in their name, or post to
    one of the .scripting.* newsgroups depending on the script language you wish
    to use (jscript or vbscript - most likely it will be jscript).

    To solve your issue, you will need to create some divs whose display
    property is initially set to "none".

    <div id=div1 style="display:none">
    relevant textboxes
    </div>
    <div id=div2 style="display:none">
    relevant textboxes
    </div>
    etc.

    Modify your SELECT tag to set the onchange event to the function you will
    use to show/hide the divs:
    <select name="lstType" id="lstType"
    onchange="return lstType_onchange();">

    Create your event handler as follows:
    <SCRIPT type="text/javascript">
    function lstType_onchange()
    {
    /*there will likely be an easier way depending on what the option values
    really are (you can probably parse the div id from the value) but
    for the
    sake of this example, I will use a switch:*/
    switch (lstType.value)
    {
    case "val_1":
    showDiv("div1")
    break
    case "val_2":
    showDiv("div2")
    break
    case "val_3":
    showDiv("div3")
    break
    case "val_4":
    showDiv("div4")
    break
    }
    }
    function showDiv(pDiv)
    {
    var i, oDiv
    var divs=new array("div1","div2", "div3","div4")
    for (var i=0;i<3;i++)
    {
    oDiv=document.getElementById(divs)
    oDiv.style.diplay = "none"
    if (divs == pDiv) {oDiv.style.diplay = "block"}
    }
    }
    </SCRIPT>

    Please follow up with any questions in a client-side scripting group.

    HTH,
    Bob Barrows
    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
     
    Bob Barrows, Apr 16, 2004
    #2
    1. Advertising

  3. Fawke101

    Randy Webb Guest

    Bob Barrows wrote:
    > Fawke101 wrote:
    >
    >>Hi there,
    >>
    >>I need a page where a user selects a value from a menu/list box, and a
    >>certain part of a form is dislpayed.
    >>Ideally (probs the easiest way for me) is to create 1 form with all
    >>the text boxes etc and then when a user selects a value from the
    >>initial list box the relative boxes are dislpayed.
    >>
    >>Any help or examples of this much appreciated.
    >>Can you have subforms of a form? if so how could i disable/enable a
    >>sub form upon selecting a list box value?
    >>
    >>*********
    >><select name="lstType" id="lstType">
    >><option selected>Please select the value......</option>
    >><option value="val_1">value1</option>
    >><option value="val_2">value2</option>
    >><option value="val_3">value3</option>
    >><option value="val_4">value4</option>
    >></select>
    >>*********

    >
    >
    > This will require client-side DHTML code, which is off-topic for this group.


    <snip>

    How is it "off-topic for this group" if its posted in
    microsoft.public.scripting.jscript ? Which is where I read it from..

    --
    Randy
    Chance Favors The Prepared Mind
    comp.lang.javascript FAQ - http://jibbering.com/faq/
     
    Randy Webb, Apr 16, 2004
    #3
  4. Fawke101

    Roland Hall Guest

    "Randy Webb" wrote in message news:p...
    : Bob Barrows wrote:
    : > Fawke101 wrote:
    : >
    : >>I need a page where a user selects a value from a menu/list box, and a
    : >>certain part of a form is dislpayed.
    : >>Ideally (probs the easiest way for me) is to create 1 form with all
    : >>the text boxes etc and then when a user selects a value from the
    : >>initial list box the relative boxes are dislpayed.
    : >>
    : >>Any help or examples of this much appreciated.
    : >>Can you have subforms of a form? if so how could i disable/enable a
    : >>sub form upon selecting a list box value?
    : >>
    : >>*********
    : >><select name="lstType" id="lstType">
    : >><option selected>Please select the value......</option>
    : >><option value="val_1">value1</option>
    : >><option value="val_2">value2</option>
    : >><option value="val_3">value3</option>
    : >><option value="val_4">value4</option>
    : >></select>
    : >>*********
    : >
    : >
    : > This will require client-side DHTML code, which is off-topic for this
    group.
    :
    : <snip>
    :
    : How is it "off-topic for this group" if its posted in
    : microsoft.public.scripting.jscript ? Which is where I read it from..

    Because it is cross posted and some of us read it in
    m.p.inetserver.asp.general.

    --
    Roland Hall
    /* This information is distributed in the hope that it will be useful, but
    without any warranty; without even the implied warranty of merchantability
    or fitness for a particular purpose. */
    Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
    WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
    MSDN Library - http://msdn.microsoft.com/library/default.asp
     
    Roland Hall, Apr 16, 2004
    #4
  5. Fawke101

    Fawke101 Guest

    Thanks for you responses guys, a great help.
    I have divided the form into a group of tables, and i would like to display
    the table in respect to which list box value is selected.

    Will the Divs solution still apply? what exactly are Divs?

    Thanks again people

    --
    Thanks in advance

    Fawke

    Please remove ANTI and SPAM
    from my email address before emailing me.

    www.bradflack.com
    "Roland Hall" <nobody@nowhere> wrote in message
    news:u$...
    > "Randy Webb" wrote in message news:p...
    > : Bob Barrows wrote:
    > : > Fawke101 wrote:
    > : >
    > : >>I need a page where a user selects a value from a menu/list box, and a
    > : >>certain part of a form is dislpayed.
    > : >>Ideally (probs the easiest way for me) is to create 1 form with all
    > : >>the text boxes etc and then when a user selects a value from the
    > : >>initial list box the relative boxes are dislpayed.
    > : >>
    > : >>Any help or examples of this much appreciated.
    > : >>Can you have subforms of a form? if so how could i disable/enable a
    > : >>sub form upon selecting a list box value?
    > : >>
    > : >>*********
    > : >><select name="lstType" id="lstType">
    > : >><option selected>Please select the value......</option>
    > : >><option value="val_1">value1</option>
    > : >><option value="val_2">value2</option>
    > : >><option value="val_3">value3</option>
    > : >><option value="val_4">value4</option>
    > : >></select>
    > : >>*********
    > : >
    > : >
    > : > This will require client-side DHTML code, which is off-topic for this
    > group.
    > :
    > : <snip>
    > :
    > : How is it "off-topic for this group" if its posted in
    > : microsoft.public.scripting.jscript ? Which is where I read it from..
    >
    > Because it is cross posted and some of us read it in
    > m.p.inetserver.asp.general.
    >
    > --
    > Roland Hall
    > /* This information is distributed in the hope that it will be useful, but
    > without any warranty; without even the implied warranty of merchantability
    > or fitness for a particular purpose. */
    > Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
    > WSH 5.6 Documentation -

    http://msdn.microsoft.com/downloads/list/webdev.asp
    > MSDN Library - http://msdn.microsoft.com/library/default.asp
    >
    >
     
    Fawke101, Apr 18, 2004
    #5
  6. Fawke101

    Bob Barrows Guest

    Fawke101 wrote:
    > Thanks for you responses guys, a great help.
    > I have divided the form into a group of tables, and i would like to
    > display the table in respect to which list box value is selected.
    >
    > Will the Divs solution still apply? what exactly are Divs?
    >

    Please remove the asp group from your crosspost. This has nothing to do with
    asp.

    (Follow-Ups set to microsoft.public.scripting.jscript)
    Bob Barrows
    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
     
    Bob Barrows, Apr 18, 2004
    #6
  7. Fawke101

    Fawke101 Guest

    my apologies....... i will continue to post in the JS newsgroup

    --
    Thanks in advance

    Fawke

    Please remove ANTI and SPAM
    from my email address before emailing me.

    www.bradflack.com
    "Fawke101" <> wrote in message
    news:...
    > Thanks for you responses guys, a great help.
    > I have divided the form into a group of tables, and i would like to

    display
    > the table in respect to which list box value is selected.
    >
    > Will the Divs solution still apply? what exactly are Divs?
    >
    > Thanks again people
    >
    > --
    > Thanks in advance
    >
    > Fawke
    >
    > Please remove ANTI and SPAM
    > from my email address before emailing me.
    >
    > www.bradflack.com
    > "Roland Hall" <nobody@nowhere> wrote in message
    > news:u$...
    > > "Randy Webb" wrote in message news:p...
    > > : Bob Barrows wrote:
    > > : > Fawke101 wrote:
    > > : >
    > > : >>I need a page where a user selects a value from a menu/list box, and

    a
    > > : >>certain part of a form is dislpayed.
    > > : >>Ideally (probs the easiest way for me) is to create 1 form with all
    > > : >>the text boxes etc and then when a user selects a value from the
    > > : >>initial list box the relative boxes are dislpayed.
    > > : >>
    > > : >>Any help or examples of this much appreciated.
    > > : >>Can you have subforms of a form? if so how could i disable/enable a
    > > : >>sub form upon selecting a list box value?
    > > : >>
    > > : >>*********
    > > : >><select name="lstType" id="lstType">
    > > : >><option selected>Please select the value......</option>
    > > : >><option value="val_1">value1</option>
    > > : >><option value="val_2">value2</option>
    > > : >><option value="val_3">value3</option>
    > > : >><option value="val_4">value4</option>
    > > : >></select>
    > > : >>*********
    > > : >
    > > : >
    > > : > This will require client-side DHTML code, which is off-topic for

    this
    > > group.
    > > :
    > > : <snip>
    > > :
    > > : How is it "off-topic for this group" if its posted in
    > > : microsoft.public.scripting.jscript ? Which is where I read it from..
    > >
    > > Because it is cross posted and some of us read it in
    > > m.p.inetserver.asp.general.
    > >
    > > --
    > > Roland Hall
    > > /* This information is distributed in the hope that it will be useful,

    but
    > > without any warranty; without even the implied warranty of

    merchantability
    > > or fitness for a particular purpose. */
    > > Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
    > > WSH 5.6 Documentation -

    > http://msdn.microsoft.com/downloads/list/webdev.asp
    > > MSDN Library - http://msdn.microsoft.com/library/default.asp
    > >
    > >

    >
    >
     
    Fawke101, Apr 18, 2004
    #7
  8. Fawke101

    Bob Barrows Guest

    Fawke101 wrote:
    > Thanks for you responses guys, a great help.
    > I have divided the form into a group of tables, and i would like to
    > display the table in respect to which list box value is selected.
    >
    > Will the Divs solution still apply? what exactly are Divs?
    >
    > Thanks again people
    >


    Same solution: only set the tables' id property and use it to set their
    display properties instead of the divs'.

    Bob Barrows

    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
     
    Bob Barrows, Apr 18, 2004
    #8
    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. Morten
    Replies:
    2
    Views:
    702
    Morten
    Dec 19, 2003
  2. Gnarlodious
    Replies:
    4
    Views:
    17,624
    elizas
    May 5, 2010
  3. Robin Cull
    Replies:
    5
    Views:
    411
    Andrew Dalke
    Jul 31, 2003
  4. Daniel Joyce

    Python Audio (Alpy, Fastaudio, Etc Etc)

    Daniel Joyce, Sep 16, 2003, in forum: Python
    Replies:
    1
    Views:
    928
    Markus Wankus
    Sep 16, 2003
  5. Kevin Walzer

    Re: PIL (etc etc etc) on OS X

    Kevin Walzer, Aug 1, 2008, in forum: Python
    Replies:
    4
    Views:
    418
    Fredrik Lundh
    Aug 13, 2008
Loading...

Share This Page