TheConeHead
Programmer
I know in Flash I can have a select that I can also enter a new entry in? Is that in HTML?
![[conehead] [conehead] [conehead]](/data/assets/smilies/conehead.gif)
![[conehead] [conehead] [conehead]](/data/assets/smilies/conehead.gif)
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
<html>
<head>
<script type="text/javascript">
function fakeCombo(x,e)
{
var S = document.getElementById("selCombo");
var L = S.options.length;
var found = false;
var myIndex = 0;
if (e.which == 13)
{
for (var i=0; i <= L-1; i++)
{
if (x.value == S.options[i].value) {found = true; myIndex = i};
}
if (found)
{
S.options.selectedIndex = myIndex;
}
else
{
S.options[S.options.length] = new Option(x.value,x.value);
S.options.selectedIndex = (S.options.length - 1);
}
return false;
}
}
</script>
</head>
<body>
<form>
<input onkeypress="JavaScript:return fakeCombo(this,event);" id="txtCombo"/><br/>
<select id="selCombo"/>
<option value="Volvo"/>Volvo
<option value="Saab"/>Saab
<option value="Fiat"/>Fiat
<option value="Audi"/>Audi
</select>
</form>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "[URL unfurl="true"]http://www.w3.org/TR/html4/strict.dtd">[/URL]
<html>
<head>
<title>new document</title>
<style type="text/css">
#main {
position: relative;
}
#main input, #main select {
position: absolute;
}
#main select {
width: 200px;
z-index: 1;
}
#main input {
width: 175px;
z-index: 2;
}
</style>
</head>
<body>
<div id="main">
<form name="f">
<input type="text" name="parts" />
<select name="sel" onchange="this.form.parts.value = this.options[this.selectedIndex].value;">
<option>Steering Wheel</option>
<option>Headlight</option>
<option>Intake Valve</option>
<option>Cam Shaft</option>
</select>
</form>
</div>
</body>
</html>
<html>
<head>
<style type="text/css">
.txtBox
{
position: absolute;
top: 20px;
left: 20px;
width: 100px;
z-index: 5;
}
.dropDown
{
position: absolute;
top: 20px;
left: 20px;
width: 120px;
z-index: 4;
}
</style>
<script type="text/javascript">
function fakeCombo(x,e)
{
var S = document.getElementById("selCombo");
var L = S.options.length;
var found = false;
var myIndex = 0;
if (e.which == 13)
{
for (var i=0; i <= L-1; i++)
{
if (x.value == S.options[i].value) {found = true; myIndex = i};
}
if (found)
{
S.options.selectedIndex = myIndex;
}
else
{
S.options[S.options.length] = new Option(x.value,x.value);
S.options.selectedIndex = (S.options.length - 1);
}
return false;
}
}
function mySelect(x)
{
document.getElementById("txtCombo").value = x.options[x.selectedIndex].value;
}
</script>
</head>
<body>
<form>
<input onkeypress="JavaScript:return fakeCombo(this,event);" id="txtCombo" class="txtBox" /><br/>
<select id="selCombo" class="dropDown" onChange="JavaScript:mySelect(this);" />
<option value="Volvo"/>Volvo
<option value="Saab"/>Saab
<option value="Fiat"/>Fiat
<option value="Audi"/>Audi
</select>
</form>
</body>
</html>