[thelist] javascript: matching values in arrays

Joshua Olson joshua at waetech.com
Fri Nov 30 21:12:59 CST 2007


> -----Original Message-----
> From: Garth Hagerman
> Sent: Friday, November 30, 2007 9:43 PM
> 
> Hi all-
> This will probaly be real easy for someone with good Javascript  
> skills; mine are shaky at best. This is part of a medical records  
> database system. To make the data entry easier, I'm writing a 
> JS which  
> matches a diagnosis code to the name of the diagnosis. 
> Currently, the  
> clerk has to type "277.3" in one field, and then 
> "Amyloidosis" in the  
> next, for example. With this script, she'll enter the code, 277.3 in  
> this example, and the Amyloidosis magically appears in the 
> next field.  
> I've got a semi-functional version of the script here:
> <http://garthhagerman.com/test.html>

I only have about 30 seconds to review this code, but here's my best guess:

function finddiag(thiscode)
	{
	for(i=1; diagcount; i++)
		{
		if(thiscode == codes[i])
			{
			document.adcond.condition.value = diagnoses[i]
			return true
			}
		}
		document.adcond.condition.value = "no match"
		return false
	}

Should be:

function finddiag(thiscode)
	{
	for(i=0; i < diagcount; i++)
		{
		if(thiscode == codes[i])
			{
			document.adcond.condition.value = diagnoses[i]
			return true
			}
		}
		document.adcond.condition.value = "no match"
		return false
	}

<><><><><><><><><><>
Joshua L. Olson
WAE Technologies, Inc.
http://www.waetech.com/
Phone: 706.210.0168
Fax: 413.812.4864
Private Enterprise Number: 28752

Monitor bandwidth usage on IIS6 in real-time:
http://www.waetech.com/services/iisbm/ 



More information about the thelist mailing list