473,387 Members | 1,882 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

editable drop-down list

Hi all,

I would like to use a control on a WebForm that acts like an editable
DropDownList control. The user should be able to select a value from
the list of choices, or type in a new value if no predefined choice is
applicable.

It doesn't appear to me that a DropDownList control is editable.

How would you suggest I accomplish what I want to do?

Thanks in advance for your help.

Aug 3 '06 #1
4 20161
Henry wrote:
Hi all,

I would like to use a control on a WebForm that acts like an editable
DropDownList control. The user should be able to select a value from
the list of choices, or type in a new value if no predefined choice is
applicable.

It doesn't appear to me that a DropDownList control is editable.

How would you suggest I accomplish what I want to do?

Thanks in advance for your help.
I have no idea what you mean by WebForm or DropDownList.
If that are some existing packages, please mention that.

If you want to edit the contents of a SELECT-element, that is easy.
Consider the following formelement:

<FORM name="myForm" Mathos="POST">
<SELECT name="myExample">
<OPTION value="John">John
<OPTION value="Joe">Joe
<OPTION value="Berta">Berta
</SELECT>
</FORM>

From javascript:
var theSelectRef = document.forms["myForm"].myExample;
var nrOfOptions = theSelectRef.options.length;

// get the first option:
var firstOption = theSelectRef[0];

// get its value:
var firstOptionValue = theSelectRef[0].value;

// remove the second option (joe)
theSelectRef.options[1] = null;

// add a new option (not added yet to SELECT):
// the third and fourth argument men: defaultSelected and Selected
var newOption = new Option("text","value",false,false);

// add it to the end:
theSelectRef[theSelectRef.options.length] = newOption;

Hope that gets you going.

Regards,
Erwin Moller

Aug 3 '06 #2
Thanks, Erwin.

I wish to apologize for my poor explanation.
Actually, I wish to have an editable HTML select control.
That means if the user cannot find the intended value from the select
control, then he can type the value himself.
In other words, the select control can also act like a text field
sometimes.

Aug 3 '06 #3
Henry wrote:
Thanks, Erwin.

I wish to apologize for my poor explanation.
Actually, I wish to have an editable HTML select control.
That means if the user cannot find the intended value from the select
control, then he can type the value himself.
In other words, the select control can also act like a text field
sometimes.
Hi,

My examplecode should easily get you going.
Pay attention to the new option example.

In short:
1) Make the SELECT and populate it with options.
2) Offer a textfield (type="text") where the client can type a new value
3) add a button "add to selectbox"
4) when button is clicked (use onClick handler), add the content of the
textfield as the new value and text to the new option.

You must be able to figure the details out yourself. If not, go get a good
JS book. :-)

Regards,
Erwin Moller
Aug 3 '06 #4
"Henry" <gg****@gmail.comwrote in news:1154596666.836253.242750
@m79g2000cwm.googlegroups.com:
Thanks, Erwin.

I wish to apologize for my poor explanation.
Actually, I wish to have an editable HTML select control.
That means if the user cannot find the intended value from the select
control, then he can type the value himself.
In other words, the select control can also act like a text field
sometimes.
Plenty of examples:

http://www.google.com/search?q=javas...22combo+box%22
Aug 3 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: ANC | last post by:
hi, i would like to ask how can i set a field of recordset to be editable? thanks in advance. ANC
17
by: black tractor | last post by:
HI there.. l was just wondering, if l place a "table" in the "editable region" of my template, will the text, graphics placed inside the this "table" MOVE BY ITSELF?? l mean, recently l had a...
0
by: David Winter | last post by:
I have a particular application that requires reordering objects by drag and drop, and I would like to do this with a web frontend. To be more precise: There are headlines and paragraphs stored...
7
by: deko | last post by:
SELECT tblTxAcct.TxAcctName, tblTxType.TxTypeName, Nz(qryTxAcctListCt.TxCount, 0) AS TxCt FROM (tblTxAcct INNER JOIN tblTxType ON tblTxAcct.TxType_ID=tblTxType.TxType_ID) LEFT JOIN qryTxAcctListCt...
4
by: Stephan Bour | last post by:
Hi, I have a datagrid databound to a SQL query. I'd like to allow editing of some columns but not all. Is there a way to turn off the conversion of the datagrid cells to textboxes for some columns...
6
by: Hako | last post by:
Hello All, I have a function to set readonly or editable of a textctrl. I'd like to make the textctrl initial set readonly and use other event funciton to set editable of the textctrl but it...
34
by: Luke | last post by:
Hi! I am new to PHP but I am a very experienced in Perl/CGI/templates. I work in medical informatics when we deal with very large data collection forms. Some of them have over 1000 elements!...
1
by: planetthoughtful | last post by:
Hi All, I have a web page that presents records in a table, with one row per record. I'd like to put an edit button next to each record, such that if a user clicks on the edit button next to...
0
by: muchinger | last post by:
All, I create 2 combo boxes on a page: an editable one and a non-editable one. Both of them have the same string items which are too long to entirely fit into the combo box. E. g. the size of...
2
by: sahista | last post by:
Hello. I create an iframe on the fly, set it to editable designMode='on' and insert into iframe.contentWindow.childNodes.childNodes some innerHTML. Ok... that all works fine in IE but in...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.