Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Help with suggestion list!  (Read 2973 times)

0 Members and 1 Guest are viewing this topic.

Mikle103

    Topic Starter


    Starter

    • Experience: Beginner
    • OS: Unknown
    Help with suggestion list!
    « on: June 23, 2011, 08:16:49 PM »
    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