can anyone explain why this code will not run in a flash form.
It has something to do with the onkeyup and on change events
How can I get it to work in Flash?
Thanks
Charlie Crimmel
It has something to do with the onkeyup and on change events
How can I get it to work in Flash?
Thanks
Charlie Crimmel
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/html4/loose.dtd">[/URL]
<html>
<head>
<title>Untitled Document</title>
</head>
<body>
<script language="JavaScript" type="text/javascript">
<!--
/*
- Give Credit Where Its Due -
Please acknowledge this article and its author, at
least in code comments, when using this code.
Author: Justin Whitford
Source: [URL unfurl="true"]www.evolt.org[/URL]
Thank you.
*/
/*
filtery(pattern, list)
pattern: a string of zero or more characters by which to filter the list
list: reference to a form object of type, select
Example:
<form name="yourForm">
<input type="text" name="yourTextField" onchange="filtery(this.value,this.form.yourSelect)">
<select name="yourSelect">
<option></option>
<option value="Australia">Australia</option>
.......
*/
function filtery(pattern, list){
/*
if the dropdown list passed in hasn't
already been backed up, we'll do that now
*/
if (!list.bak){
/*
We're going to attach an array to the select object
where we'll keep a backup of the original dropdown list
*/
list.bak = new Array();
for (n=0;n<list.length;n++){
list.bak[list.bak.length] = new Array(list[n].value, list[n].text);
}
}
/*
We're going to iterate through the backed up dropdown
list. If an item matches, it is added to the list of
matches. If not, then it is added to the list of non matches.
*/
match = new Array();
nomatch = new Array();
for (n=0;n<list.bak.length;n++){
if(list.bak[n][1].toLowerCase().indexOf(pattern.toLowerCase())!=-1){
match[match.length] = new Array(list.bak[n][0], list.bak[n][1]);
}else{
nomatch[nomatch.length] = new Array(list.bak[n][0], list.bak[n][1]);
}
}
/*
Now we completely rewrite the dropdown list.
First we write in the matches, then we write
in the non matches
*/
for (n=0;n<match.length;n++){
list[n].value = match[n][0];
list[n].text = match[n][1];
}
for (n=0;n<nomatch.length;n++){
list[n+match.length].value = nomatch[n][0];
list[n+match.length].text = nomatch[n][1];
}
/*
Finally, we make the 1st item selected - this
makes sure that the matching options are
immediately apparent
*/
list.selectedIndex=0;
}
// -->
</script>
<!-- ----------------------- start 1 Option no Tables--------------- -->
<cfform name="search1" height="600" width="1000">
<cfformgroup type="horizontal">
<cfformgroup type="hbox" width="400">
<cfformgroup type="panel" label="Filter Dropdown From Options" width="375">
Search <cfinput type="text" name="yourTextField" onkeyup="filtery(this.value,this.form.yourSelect)" onchange="filtery(this.value,this.form.yourSelect)">
<cfselect name="yourSelect" width="200">
<option></option>
<option value="Alabama">Alabama</option> <option value="Alaska">Alaska</option> <option value="Arizona">Arizona</option>
<option value="Arkansas">Arkansas</option> <option value="California">California</option> <option value="Colorado">Colorado</option>
<option value="Connecticut">Connecticut</option> <option value="Delaware">Delaware</option>
</cfselect>
</cfformgroup></cfformgroup>
</cfformgroup
</cfform>
</body>
</html>