Currently I am taking a value from a text box, validating that it is a known value(only certain values can be entered), then if it is not within the select box I add the value to the select box, then whipe out the text value. I have tried to give the focus back to the text box after all of this, but it never happens. here is the code.
<script language="Javascript">
var uicstr;
function popUicArray(thestr)
{
uicstr = thestr;
}
function findUic(theuic)
{
if(theuic != "")
{
var found = uicstr.indexOf(theuic);
// alert(uicstr + ' ' + theuic);
if(notinfinal(theuic))
{
if(found != -1)
{
CPOCommandForm.uic.length+
+;
CPOCommandForm.uic[CPOComm
andForm.ui
c.length-1
].text = theuic;
CPOCommandForm.entryuic.va
lue = "";
CPOCommandForm.entryuic.fo
cus();
}
else
{
alert("That uic could not be found. Please try again.");
}
}
}
else
CPOCommandForm.entryuic.fo
cus();
CPOCommandForm.entryuic.fo
cus();
}
function notinfinal(theuic)
{
for (var i=0; i < CPOCommandForm.uic.options
.length; i++)
{
if(CPOCommandForm.uic.opti
ons[i].tex
t == theuic)
{
//found that uic in the list so return false
return false;
}
}
// was not in the list
return true;
}
</script>
The uicstr is populated earlier. Here is how the text input calls the function:
<td valign="top" align="left">
<input type="text" name="entryuic" onchange="findUic(this.val
ue)" size="5" maxlength="5">
</td>
<td>
<select name="uic" style="height: 150px" size="5" onDblClick="removeSelectio
n(CPOComma
ndForm.uic
.selectedI
ndex)"></s
elect></td
>
Any Ideas?
Thanks
Ben Switzer
Start Free Trial