Print Page | Close Window

<SELECT> not limited to list

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Web Design Discussion
Forum Description: Discussion on web design and development subjects.
URL: https://forums.webwiz.net/forum_posts.asp?TID=5540
Printed Date: 28 March 2026 at 5:51am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: <SELECT> not limited to list
Posted By: Gary
Subject: <SELECT> not limited to list
Date Posted: 05 September 2003 at 2:53am

Not sure if this is possible with <SLEECT> or anything similar....

Basically, I have an asp order form which includes delivery details (company, address, etc). There is a table which contains aon address book which I want to put into a <SELECT> so that the users can choose a company and the form will self-populate with the associated address details - no problems.

However, I dont want to limit the user to the <OPTION>'s in the <SELECT> list. I want them to be able to type in other company names (ie not limited to the list).

Is this possible with <SELECT>, is there something else that I should be using, or am I thinking of some other technology (eg Visual Basic / MS Access forms) ???

Cheers




Replies:
Posted By: KCWebMonkey
Date Posted: 05 September 2003 at 12:07pm

One possible Solution:

Form Code:
<SELECT NAME="selectCompany">
<option value="company1">Company 1</option>
<option value="company2">Company 2</option>
<option value="company3">Company 3</option>
</SELECT>
or
<INPUT TYPE="text" NAME="inputCompany">

ASP Code:
<%
Dim userCompany, selectCompany, inputCompany
selectCompany = Request.Form("selectCompany")
inputCompany = Request.Form("inputCompany")
If Not selectCompany = "" Then
userCompany = selectCompany
ElseIf Not inputCompany = "" Then
userCompany = inputCompany
End If
%>



Posted By: Gary
Date Posted: 06 September 2003 at 1:54pm

That is the only solution that I am aware of....

What I am after is a single entry point rather than the option of selecting from a <SELECT> or entering into an <INPUT>.

I guess my requirement is just not possible



Posted By: KCWebMonkey
Date Posted: 07 September 2003 at 9:17am

well, there's no way to enter text in to a <select> box of course...

I guess there would be a way to scroll through the company names in a text box with JavaScript, so the user could either choose one of them or enter their own...



Posted By: Bluefrog
Date Posted: 19 September 2003 at 9:44am

The solution here isn't obvious. Create another option like <option value="custom"> Enter a new company...</option>.

Add an onChange event to the SELECT tag. Pass the value to a javascript function.

In the JS function, unhide a hidden INPUT element. Prompt the user to enter the new thing.

Have a button that says something like "Add company". Get the user to click it.

With the button, have an onClick event. With that, grab the value in the INPUT element...

Use:

document.formName.selectName.options[document.formName.selec tName.selectedIndex].value

To access and replace 'custom'.

Hide the INPUT.

Tada.

Sorry I don't have more time to give you working code, but that will do it if you fiddle around and do it in small pieces.

The trick is that you never 'CHANGE' the select... you only unhide an INPUT, get what you want, then replace/add a new field in the SELECT. (There are a few extras that you'll need to do as well, but that should get you started.)

Cheers

 




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net