benslayton
01-15-2007, 08:30 PM
instead of "place1,place2, and place3 the showing up in the text box. I actually want a small description to go in the textbox instead of what is in the listbox.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<SCRIPT>
<!--
function combotext_onkeydown(e,oText,oSelect){
keyCode = e.keyCode;
if (keyCode == 40 || keyCode == 38) {
oSelect.style.display = 'block';
oSelect.focus();
comboselect_onchange(oSelect, oText);
}
else if (keyCode == 13) {
e.cancelBubble = true;
if (e.returnValue) e.returnValue = false;
if (e.stopPropagation) e.stopPropagation();
comboselect_onchange(oSelect, oText);
oSelect.style.display='none';
oText.focus();
return false;
}
else if(keyCode == 9) return true;
else { //alert(keyCode);
oSelect.style.display = 'block';
var c = String.fromCharCode(keyCode);
c = c.toUpperCase();
toFind = oText.value.toUpperCase() + c;
for (i=0; i < oSelect.options.length; i++){
nextOptionText = oSelect.options.text.toUpperCase();
if(toFind == nextOptionText){
oSelect.selectedIndex = i;
break;
}
if(i < oSelect.options.length-1){
lookAheadOptionText = oSelect.options[i+1].text.toUpperCase() ;
if( (toFind > nextOptionText) &&
(toFind < lookAheadOptionText) ){
oSelect.selectedIndex = i+1;
break;
}
}
else {
if(toFind > nextOptionText){
oSelect.selectedIndex = oSelect.options.length-1; // stick it at the end
break;
}
}
}
}
}
function comboselect_onchange(oSelect,oText) {
if(oSelect.selectedIndex != -1)
oText.value = oSelect.options[oSelect.selectedIndex].text;
}
function comboselect_onkeyup(keyCode,oSelect,oText){
if (keyCode == 13) {
comboselect_onchange(oSelect, oText);
oSelect.style.display='none';
oText.focus();
}
}
// -->
</SCRIPT>
<body>
<FORM name="form1">
<table width="617" border="1" align="center" bordercolor="#990000">
<tr>
<th scope="col">Places</th>
<th scope="col">Description</th>
</tr>
<tr>
<th width="219" scope="row"> <SELECT NAME="selectInput1" SIZE="8" ONCHANGE="comboselect_onchange(this, this.form.textInput)" >
<option>place1</option>
<option>place2</option>
<option>place3</option>
</SELECT> </th>
<th width="382" scope="row">
<textarea name="textInput" cols="20" rows="10" id="textInput"></textarea> </th>
</tr>
</table>
</FORM>
</BODY>
</html>
Any Help?:)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<SCRIPT>
<!--
function combotext_onkeydown(e,oText,oSelect){
keyCode = e.keyCode;
if (keyCode == 40 || keyCode == 38) {
oSelect.style.display = 'block';
oSelect.focus();
comboselect_onchange(oSelect, oText);
}
else if (keyCode == 13) {
e.cancelBubble = true;
if (e.returnValue) e.returnValue = false;
if (e.stopPropagation) e.stopPropagation();
comboselect_onchange(oSelect, oText);
oSelect.style.display='none';
oText.focus();
return false;
}
else if(keyCode == 9) return true;
else { //alert(keyCode);
oSelect.style.display = 'block';
var c = String.fromCharCode(keyCode);
c = c.toUpperCase();
toFind = oText.value.toUpperCase() + c;
for (i=0; i < oSelect.options.length; i++){
nextOptionText = oSelect.options.text.toUpperCase();
if(toFind == nextOptionText){
oSelect.selectedIndex = i;
break;
}
if(i < oSelect.options.length-1){
lookAheadOptionText = oSelect.options[i+1].text.toUpperCase() ;
if( (toFind > nextOptionText) &&
(toFind < lookAheadOptionText) ){
oSelect.selectedIndex = i+1;
break;
}
}
else {
if(toFind > nextOptionText){
oSelect.selectedIndex = oSelect.options.length-1; // stick it at the end
break;
}
}
}
}
}
function comboselect_onchange(oSelect,oText) {
if(oSelect.selectedIndex != -1)
oText.value = oSelect.options[oSelect.selectedIndex].text;
}
function comboselect_onkeyup(keyCode,oSelect,oText){
if (keyCode == 13) {
comboselect_onchange(oSelect, oText);
oSelect.style.display='none';
oText.focus();
}
}
// -->
</SCRIPT>
<body>
<FORM name="form1">
<table width="617" border="1" align="center" bordercolor="#990000">
<tr>
<th scope="col">Places</th>
<th scope="col">Description</th>
</tr>
<tr>
<th width="219" scope="row"> <SELECT NAME="selectInput1" SIZE="8" ONCHANGE="comboselect_onchange(this, this.form.textInput)" >
<option>place1</option>
<option>place2</option>
<option>place3</option>
</SELECT> </th>
<th width="382" scope="row">
<textarea name="textInput" cols="20" rows="10" id="textInput"></textarea> </th>
</tr>
</table>
</FORM>
</BODY>
</html>
Any Help?:)