1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
| <script type="text/javascript">
var functionlist = [];
<?php
$results= mysql_query("SELECT distinct cod_str, den_str from bucstr WHERE '".$_GET[sucursal]."' = JUDET Order by den_str asc",$conn);
$id = "cod_str";
$idname = "den_str";
// Get Data From Result
if (mysql_Numrows($results)>0)
{
$numrows=mysql_NumRows($results);
$x=0;
while ($x<$numrows)
{
$theId=mysql_result($results,$x,$id);
$theName=mysql_result($results,$x,$idname);
echo("functionlist.push('$theName');\n");
$x++;
}
}
?>
function handleKeyUp(maxNumToShow)
{
var selectObj, textObj, functionListLength;
var i, searchPattern, numShown;
// Set references to the form elements
selectObj = document.forms[0].functionselect;
textObj = document.forms[0].functioninput;
// Remember the function list length for loop speedup
functionListLength = functionlist.length;
// Set the search pattern depending
if(document.forms[0].functionradio[0].checked == true)
{
searchPattern = "^"+textObj.value;
}
else
{
searchPattern = textObj.value;
}
// Create a regulare expression
re = new RegExp(searchPattern,"gi");
// Clear the options list
selectObj.length = 0;
// Loop through the array and re-add matching options
numShown = 0;
for(i = 0; i < functionListLength; i++)
{
if(functionlist[i].search(re) != -1)
{
selectObj[numShown] = new Option(functionlist[i],"");
numShown++;
}
// Stop when the number to show is reached
if(numShown == maxNumToShow)
{
break;
}
}
// When options list whittled to one, select that entry
if(selectObj.length == 1)
{
selectObj.options[0].selected = true;
}
}
function handleSelectClick()
{
selectObj = document.forms[0].functionselect;
textObj = document.forms[0].functioninput;
selectedValue = selectObj.options[selectObj.selectedIndex].text;
// selectedValue = selectedValue.replace(/_/g, '-') ;
form.submit();
}
</script> |
Partager