Okay, I'm in way over my head here, if it's this hard to fix JavaScript, I need to do something else. If you told me to fix similar things in php maybe I could, but none of this means anything to me and it's a waste of your time.
I got this today from CodingForums, it works beautifully - but again, it has the options in the JS. Is this another case where it can't use the php options?
If so I think I will just make a really long options list with the 60-70 genus names, that will solve all our problems! Except that then it won't be dynamic related to the GENUS table, which hopefully will grow over time... So it's good code, bad database use.
<HTML>
<Head>
<Script Language=JavaScript>
var smartOptions = new Array();
var allOptions = new Array();
allOptions[0] = "Babich, Timothy";
allOptions[1] = "Cahoon, Ron";
allOptions[2] = "Atwood, James";
allOptions[3] = "Cannon, Edith";
allOptions[4] = "Allen, Mike";
allOptions[5] = "Bailey, Mary";
allOptions[6] = "Aaron, Daniel";
allOptions[7] = "Alexander, Allison";
allOptions[8] = "Baker, George";
allOptions[9] = "Conner, Anthony";
function buildSmartOptions(isForm){
matchStr = isForm.isText.value.toLowerCase();
if (matchStr != "")
{
smartOptions.length = 0;
n = 0;
endClip = matchStr.length;
for (i=0; i<allOptions.length; i++)
{
if (matchStr == allOptions[i].slice(0,endClip).toLowerCase())
{smartOptions[n++] = allOptions[i]}
}
isForm.isList.length = 1;
for (i=0; i<smartOptions.length; i++)
{
isData = new Option(smartOptions[i],smartOptions[i]);
isForm.isList.add(isData,isForm.isList.options.length);
}
if (smartOptions.length > 5){isForm.isList.size=6}
else {isForm.isList.size = smartOptions.length+1}
}
if (matchStr == ""){init()}
}
function getChoice(isChoice){
alert(isChoice);
}
function init(){
isForm = document.forms.Form1;
isForm.isList.length = 1;
isForm.isList.size = 1;
allOptions.sort();
for (i=0; i<allOptions.length; i++)
{
isData = new Option(allOptions[i],allOptions[i]);
isForm.isList.add(isData,isForm.isList.options.length);
}
isForm.isText.focus();
}
window.onload=init;
</Script>
</Head>
<Body>
<Form name='Form1'>
<Table align='center' cellspacing='0' cellpadding='2' style='border:solid black 1px;font-family:Arial;font-weight:bold;font-size:12pt;width:200px;height:110px;background-color:lightyellow'>
<THead>
<TR><TH colspan='2' height='25' bgcolor='lightblue'>Name List</TH></TR>
</THead>
<TBody>
<TR>
<TD align='right' style='font-size:11pt'>Trim At:</TD>
<TD><input type='text' name='isText' size='15' onkeyup="buildSmartOptions(this.form)"></TD>
</TR>
<TR>
<TD align='center' colspan='2'>
<Select name='isList' onchange="getChoice(this.value)" style='width:151px'>
<option selected value='null'>Make a Selection</option>
</Select>
</TD>
</TR>
</TBody>
</Table>
</Form>
</Body>
</HTML></body>
</html>