hi all,
I'm new to PHP and Java script, but would like to get som experience with em'.
Im trying to make a search for a dropdown list, but it doesnt work?
It is based heavily on this code http://www.rgagnon.com/jsdetails/js-0089.html (wich works fine?)
I have testet to see if the searchSel() gets called, and it does. but the dropdown doesnt update?
If i hard code the option values it works, so I guess there are something wrong with the PHP? even tho the resulting source is identical to the hardcoded?
Any help you be apreciated
- hmortensen
<HTML><HEAD><SCRIPT type="text/javascript">
function searchSel() {
var input=document.getElementById('realtxt').value.toLowerCase();
var output=document.getElementById('realitems').options;
for(var i=0;i<output.length;i++) {
if(output[i].value.indexOf(input)==0){
output[i].selected=true;
}
if(document.forms[0].realtxt.value==''){
output[0].selected=true;
}
}
}
</SCRIPT>
</HEAD><BODY>
<FORM>
Search <input type="text" id="realtxt" onkeyup="searchSel()">
<SELECT id="realitems">
<OPTION value="">Select...
<?php
$myMediaList = array();
$f = file("c:\\ItemsList.txt");
foreach ($f as $line) {
if (strpos($line,'|') !== false)
{
list($name, $location) = explode("|",$line);
$myMediaList[trim($name)] = trim($location);
}
}
foreach(array_keys($myMediaList) as $thekey)
{
echo '<OPTION value="', $myMediaList[$thekey], '">' , $thekey , "\r\n";
}
?>
</SELECT>
</FORM></BODY></HTML>
The file "c:\\ItemsList.txt" contains:
Me|Programmer
Myself|PHP Programmer
Irene|Girl