Solved

Combo box in HTML form?

Posted on 2004-04-29
2
256,587 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 100 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…

726 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