?
Solved

Combo box in HTML form?

Posted on 2004-04-29
2
Medium Priority
?
256,610 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
Suggested Courses

765 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