...

View Full Version : select box?



nikko50
01-19-2006, 04:37 PM
How can I change a select list depending what a user types in a text box?
I'm just trying to grab the first 10 charactors of the text field and see if they match a particular string and then change the select list if they do.

<script>
function selectOption(oTxt){
var sel = oTxt.form.selName;
if (oTxt.value.substring(0,9)== "1Z9R29A403"){

//MAKE SELECT LIST CHANGE TO VALUE "01" WHICH IS UPS NEXT DAY
}
}
</script>

<form method="POST" onSubmit="return false" >
<p><input type="text" name="id" size="20" onkeyup="selectOption(this)" onblur="selectOption(this)"></p>
<p><select size="1" name="selName">
<option value="01">UPS NEXT DAY</option>
<option value="02">UPS SECOND DAY</option>
<option value="03">UPS GROUND</option>
<option value="" selected>Select One</option>
</select></p>
</form>

A1ien51
01-19-2006, 05:36 PM
whooops wrong thread

vwphillips
01-19-2006, 05:39 PM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>
<title></title>
</head>

<body>

<script>
function selectOption(oTxt,sel){
var sel=document.getElementById(sel)
for (var zxc0=0;zxc0<sel.options.length;zxc0++){
if (oTxt.value.toLowerCase()==sel.options[zxc0].text.substring(0,oTxt.value.length).toLowerCase()){
sel.selectedIndex=zxc0;
break;
}

}
}
</script>

<form method="POST" onSubmit="return false" >
<p><input type="text" name="id" size="20" onkeyup="selectOption(this,'selName')" onblur="selectOption(this,'selName')"></p>
<p><select size="1" name="selName" id="selName">
<option value="01">UPS NEXT DAY</option>
<option value="02">UPS SECOND DAY</option>
<option value="03">UPS GROUND</option>
<option value="" selected>Select One</option>
</select></p>
</form>
</body>

</html>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum