Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Combo box in HTML form?

Posted on 2004-04-29
2
Medium Priority
?
256,624 Views
Last Modified: 2011-08-18
I'm making a form with HTML--I'm still learning, but I haven't found a way to have a scroll menu that lets you choose OR enter a new value that then gets added to list. I've done something like this with databases (I think it's called a combo box), I'm just not sure whether it's do-able with HTML.

Example: I want a user to enter a species name. They can choose from maple, birch, or hickory. But this year, there's a new species to consider: tulip. How can I make it so that the visitor can enter this value that is not already on the list? And is it possible to have this new value automatically appended to the list?

Here's what I have so far:  


    <select name="menu" size="3" multiple>

        <option value="1">maple</option>

        <option value="2">hickory</option>

        <option value="3">birch</option>

    </select>

</form>

Thanks in advance for your help.

-Krystle
0
Comment
Question by:KrystleBlair
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 31

Accepted Solution

by:
seanpowell earned 300 total points
ID: 10954384
Have a read through this:
http://www.cs.tut.fi/~jkorpela/forms/combo.html
Let us know if you need more info...

Thanks,
Sean

0
 
LVL 1

Expert Comment

by:garethdart24
ID: 10966373
You could use a javascript solution:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>Untitled</title>
<style>
</style>
<script language = "javascript">
<!--
var firstBit1 = "<select name='menu' id = 'menu' size='";
var firstBit2 = "' multiple='multiple'>";
var orig_conts = "<option selectec value='1'>maple<option value='2'>hickory<option value='3'>birch</option>";
var lastBit = "</select>";
var size = 3;
var x = 3;

function initRefresh() {

//replace size with x to make the dropdown list increase in vertical size with each selection
document.getElementById('div').innerHTML = firstBit1 + size + firstBit2 + orig_conts + lastBit;

}

function addItem() {

x++;
orig_conts =  "<option value = '" + x + "'>" + document.form.add.value + "</option>" + orig_conts;
initRefresh();
document.form.add.value = "";
document.form.menu.selectedIndex = 0;

}

//-->
</script>
</head>
<body onload = "initRefresh()">
<form name = "form" id = "form">
<div name = "div" id = "div"></div>
<input type = "text" name = "add" id = "add"><br>
<input type = "button" value = "Click" onclick = "addItem()">

</form>
</body>
</html>

Hope that's helpful,

G
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question