1.

Solve : Help with suggestion list!?

Answer»

Hey All  am new at this and have problems!!!

I wish to fill a dropdown LIST with suggestion of products dependant one user input!
I have a CSV fil with each product code on a new line!
I think I need to place CSV into and ARRAY and I think it is don as FOLLOWS?
Code: [Select]function FillArray()
{
   var ProdCSV = '/inc/product.csv';
   datafile = new File(ProdCSV);
   datafile.open('r');
   var ProdArr = new Array();
   while(!datafile.eof)
      {
      ProdArr.push(new Array(datafile.readln()));
      }
   datafile.close();
   return ProdArr;
}

Now my main code as a base is as follows also wish to hide and unhide the list when input field is blank or is a item in array not part!
 
Code: [Select]<head>
   <script TYPE='text/javascript'>
   var ProdArr = FillArray();
   </script>
</head>
 
<body>
   <form>
      Product - <input NAME="model_1" type="text" id="model_1" size=16 maxlength=16 onchange="NearestProd(this,ProdArr);" /><br />
      <textarea name="neartxt" id="neartxt" cols=16 rows=5></textarea>
   </form>
</body>

I am unsure if this is correct and a start?
Code: [Select]function NearestProd(data, ProdArr)
{
   
    if (data=="" || data==ProdArr[item??]
      {
       hide textare???
      }
   else
     }
     fill textarea with list of suggestions based on data
     text areas size to change with rows being maxed at 5 if more scrollbar active
     }   
}

many thanks in advance
 
Mikle



Discussion

No Comment Found