You will (at least) need to reverse the comparisons to consider the new sort
order:
if (sSubstr < sInput)
{
// Search the upper half of the branch
iLow = iCurrent + 1;
}
else if (sSubstr > sInput)
Change to
if (sSubstr > sInput)
{
// Search the upper half of the branch
iLow = iCurrent + 1;
}
else if (sSubstr < sInput)
etc.
HTH,
Tore.
-----Original Message-----
From: Timothy Owen [mailto:[EMAIL PROTECTED]]
Sent: Monday, September 09, 2002 11:29 AM
To: ActiveServerPages
Subject: OT- java problem
I was asked recently to edit a ASP page that generates the following
HTML so that the drop down was in descending order. I did that. It was
as simple as editing the SQL statement. Now a piece of Java code that
was working to allow the user to type in box A to select an item in the
dropdown is not working. If I revert the dropdown to the original
ascending sort order it works fine again. Is there anyone out there
that might like to help with this? Below is the entire original html
document.
Html to follow - watch for wrap.
////
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title></title>
</head>
<script type="text/javascript" language="javascript">
function SmartSelect(oInput, oSelect)
{
var sInput = String(oInput.value).toUpperCase();
var iLength = sInput.length;
if (iLength <= 0)
return -1;
var oOptions = oSelect.options;
var i, diff, bFound, sTemp;
var iHigh = oOptions.length - 1;
var iLow = 0;
var iCurrent = Math.floor((iHigh + 1) / 2);
bFound = false;
do
{
// Get the current option
sTemp = oOptions(iCurrent).value.toUpperCase();
var sSubstr = sTemp.substr(0, iLength);
if (sSubstr < sInput)
{
// Search the upper half of the branch
iLow = iCurrent + 1;
}
else if (sSubstr > sInput)
{
// Search the lower half of the branch
iHigh = iCurrent - 1;
}
else
{
bFound = true;
break;
}
// Pick the middle of the branch again
iCurrent = Math.floor(iLow + ((iHigh + 1) - iLow) / 2);
} while (iHigh >= iLow)
// Is there a better prefix match?
if (iLength < sTemp.length)
{
// Store the current old value
var iOld = iCurrent--;
// Now go back until we find one that doesn't match the
prefix
while (iCurrent >= 0)
{
// Gone too far -- the prefix no longer matches.
if
(oOptions(iCurrent).value.toUpperCase().substr(0, iLength) != sInput)
break;
iOld = iCurrent--;
}
iCurrent = iOld;
}
if (bFound)
return iCurrent;
else
return -1;
}
function DoIt()
{
var i = SmartSelect(document.all("a"), document.all("b"));
document.all("b").selectedIndex = i;
}
</script>
<body style="font-family: helvetica, arial;">
<div align="center">
<center>
<table border="0" width="600" bgcolor="#F0F0F0">
<tr>
<td width="100%">
<form method="POST" action="parts_choose_drawing_review.asp"
name="FrontPage_Form1" onsubmit="return FrontPage_Form1_Validator(this)"
language="JavaScript">
<p align="center">Please choose a drawing number to review
parts for.<font size="2"></font></p>
<div align="center">
<center>
<table border="0" width="80%">
<tr>
<td width="100%">
<table border="0" width="100%">
<tr>
<td width="100%" colspan="2" valign="top">
<p align="center">
<select size="1" name="drawing_number" id="b">
<option value="Please Choose">Please Choose</option>
<option value="4550">4550</option>
<option value="4549">4549</option>
<option value="4548">4548</option>
<option value="4547">4547</option>
<option value="4546">4546</option>
<option value="4545">4545</option>
<option value="4544">4544</option>
<option value="4543">4543</option>
<option value="4542">4542</option>
<option value="4541">4541</option>
<option value="4540">4540</option>
<option value="4539">4539</option>
<option value="4538">4538</option>
<option value="4537">4537</option>
<option value="4536">4536</option>
<option value="4535">4535</option>
<option value="4534">4534</option>
<option value="4533">4533</option>
<option value="4532">4532</option>
<option value="4531">4531</option>
<option value="4530">4530</option>
<option value="4529">4529</option>
<option value="4528">4528</option>
<option value="4527">4527</option>
<option value="4526">4526</option>
<option value="4525">4525</option>
<option value="4524">4524</option>
<option value="4523">4523</option>
<option value="4522">4522</option>
<option value="4521">4521</option>
<option value="4520">4520</option>
<option value="4519">4519</option>
<option value="4518">4518</option>
<option value="4517">4517</option>
<option value="4516">4516</option>
<option value="4515">4515</option>
<option value="4514">4514</option>
<option value="4513">4513</option>
<option value="4512">4512</option>
<option value="4511">4511</option>
<option value="4510">4510</option>
<option value="4509">4509</option>
<option value="4508">4508</option>
<option value="4507">4507</option>
<option value="4506">4506</option>
<option value="4505">4505</option>
<option value="4504">4504</option>
<option value="4503">4503</option>
<option value="4502">4502</option>
<option value="4501">4501</option>
<option value="4500">4500</option>
<option value="4499">4499</option>
<option value="4498">4498</option>
<option value="4497">4497</option>
<option value="4496">4496</option>
<option value="4495">4495</option>
<option value="4494">4494</option>
<option value="4493">4493</option>
<option value="4492">4492</option>
</select></td>
</tr>
<tr>
<td width="50%" valign="top"></td>
<td width="50%" valign="top"></td>
</tr>
<tr>
<td width="50%" valign="top"><b><font
size="2">Quick
finder:</font></b><br>
<font size="1">Enter the drawing number that you
are
looking for here. If the drawing number is
valid
it will appear in the dropdown box above.
Once you
have located the proper drawing number, press
submit.</font></td>
<td width="50%" valign="top">
<input type="test" id="a" onkeyup="DoIt()"
size="20"></td>
</tr>
</table>
</td>
</tr>
</table>
</center>
</div>
</center>
<p align="right"><input type="submit" value="Submit"
name="Submit"></p>
</form>
</td>
</tr>
<center>
</table>
</center>
</div>
</body>
</html>
---
You are currently subscribed to activeserverpages as: [EMAIL PROTECTED]
To unsubscribe send a blank email to
%%email.unsub%%
---
You are currently subscribed to activeserverpages as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED]