editable dropdown/list field

Discussion in 'ASP General' started by Paul, Jul 8, 2008.

  1. Paul

    Paul Guest

    Hi all,

    I have a page that has a form on it which has a dropdown list on it. It
    connect to an sql database and populate the list. What I would like to do is
    make the list editable so that if the data returned doesnt contain what I
    want, I can type in the data I require which will then be updated to the
    database when the form is posted.

    Hope I've made sense, you may be able to tell I'm a bit of a newbie!

    Any help would be really appreciated!

    Thanks in advance
     
    Paul, Jul 8, 2008
    #1
    1. Advertising

  2. Paul

    Evertjan. Guest

    Paul wrote on 08 jul 2008 in microsoft.public.inetserver.asp.general:

    > Hi all,
    >
    > I have a page that has a form on it which has a dropdown list on it.
    > It connect to an sql database and populate the list. What I would like
    > to do is make the list editable so that if the data returned doesnt
    > contain what I want, I can type in the data I require which will then
    > be updated to the database when the form is posted.
    >
    > Hope I've made sense, you may be able to tell I'm a bit of a newbie!


    ASP has no dropdown lists, you will need to do this clientside.


    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., Jul 8, 2008
    #2
    1. Advertising

  3. Paul wrote:
    > Hi all,
    >
    > I have a page that has a form on it which has a dropdown list on it.
    > It connect to an sql database and populate the list. What I would
    > like to do is make the list editable so that if the data returned
    > doesnt contain what I want, I can type in the data I require which
    > will then be updated to the database when the form is posted.
    >


    Your question does not make clear whether you wish to use the new value in
    subsequent dropdown lists, or whether you just want to process the value but
    leave the dropdown list unaltered. I will assume that you want the value to
    appear in subsequent dropdown lists.

    > Hope I've made sense, you may be able to tell I'm a bit of a newbie!
    >
    > Any help would be really appreciated!
    >

    You will need to use an additional input element whose name is set to
    "txtNewListValue" for example.

    When the form is submitted, the server-side code asp page that is requested
    needs to check to see if any text was entered in the element, like this:

    <%
    ....
    'Do this before opening the recordset from which the
    'dropdown values are generated
    dim dropdownvalue
    if len(Request.Form("txtNewListValue")) > 0 then
    'use ADO to insert the new value into the database
    dropdownvalue=Request.Form("txtNewListValue")
    else
    dropdownvalue=Request.Form("dropdownelement")
    end if
    ....
    open the recordset from which the
    'dropdown list is populated

    %.

    --
    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 [MVP], Jul 8, 2008
    #3
  4. Paul

    Old Pedant Guest

    What you are looking for is what Windows calls a "combo-box". And it's a
    quite common feature in Windows-based forms.

    But HTML doesn't support one. At least not directly.

    It's not too hard to create the *appearance* of one using JavaScript, but if
    you intend it to work with all browsers you have to be pretty careful in
    constructing it.

    You might do a Google search for "html combo box" or "javascript combo box"
    and see if you get any hits.

    As Bob Barrows showed, it's pretty easy to get the same functionality by
    using both a <SELECT> and an <INPUT> field, but yes, if you can do it
    "prettier" using JS and CSS it can have a nice effect.
     
    Old Pedant, Jul 8, 2008
    #4
  5. Paul

    Paul Guest

    Many thanks for your assistance.

    After everything, I cheated a bit and just made a link to another form which
    allowed me to do what i wanted!

    thanks again
    "Paul" <> wrote in message
    news:D...
    > Hi all,
    >
    > I have a page that has a form on it which has a dropdown list on it. It
    > connect to an sql database and populate the list. What I would like to do
    > is make the list editable so that if the data returned doesnt contain what
    > I want, I can type in the data I require which will then be updated to the
    > database when the form is posted.
    >
    > Hope I've made sense, you may be able to tell I'm a bit of a newbie!
    >
    > Any help would be really appreciated!
    >
    > Thanks in advance
     
    Paul, Jul 11, 2008
    #5
    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. george d lake
    Replies:
    0
    Views:
    929
    george d lake
    Oct 30, 2003
  2. Kenneth Keeley

    Editable Dropdown List

    Kenneth Keeley, Dec 3, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    15,813
    George Birbilis
    Dec 3, 2003
  3. Larry Rekow
    Replies:
    1
    Views:
    3,705
    Lucas Tam
    Aug 29, 2004
  4. =?Utf-8?B?QW1pdC5ORVQ=?=

    Editable Dropdown list control in ASP.NET 2.0

    =?Utf-8?B?QW1pdC5ORVQ=?=, Oct 17, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    4,635
    Eliyahu Goldin
    Oct 17, 2006
  5. ashish_gokhale

    Editable dropdown list

    ashish_gokhale, Jan 27, 2005, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    292
    Ken Cox [Microsoft MVP]
    Jan 27, 2005
Loading...

Share This Page