Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form will not work in flash

Status
Not open for further replies.

crimmelcp

Programmer
Oct 13, 2004
31
0
0
US
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

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>
 
um, can you use JS functions like that in flash?

Beware of programmers who carry screwdrivers.
 
I dont know, Thats why I am asking for help.
Thecfselect command has a on key up and down
and you should be able to use javasript of action script, but I do not know how to code them.

Charlie Crimmel
 
i'm not sure if you can use javascript in a flash form. ask the flash forum. i do know the onkeyup and onkeydown aren't supported in html select boxes, trust me i've tried. text boxes and text areas only i think. you'll have to use onblur i believe.

Beware of programmers who carry screwdrivers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top