editable dropdown/list field

P

Paul

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
 
E

Evertjan.

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.
 
B

Bob Barrows [MVP]

Paul said:
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

%.
 
O

Old Pedant

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.
 
P

Paul

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,239
Members
46,827
Latest member
DMUK_Beginner

Latest Threads

Top