1

im really new to javascript and its kinda my first time project,

Im trying to basicaly do a search box where i could input a Client id or email and to get a result

actually the code working because im manually filling the source, but is it possible to read it from a .txt or a .csv and if yes how to keep the same layout

the layout is :

{   IDCLIENT12345 email@gmail.com 20/09/2022  50EUR   AMAZON  <a href="https://127.0.0.1">lien</a>    }

bellow my code

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html><meta http-equiv="content-type" content="text/html;charset=utf-8">
<head>
<style>*{font-family:arial;font-size:12px;}</style>
<script type="text/javascript">function ok_onclick(){n=document.getElementById("champ").value;i=0;if (n==0){re1="{1,6}";re2="*";} else {re1="{"+(n-1)+"}";re2="{"+(6-n)+"}";};t=document.getElementById("tout").value;s=document.getElementById("source").value;re=new RegExp("^\{\t(([^}\t]*\t)"+re1+"[^}\t]*" + t + "[^}\t]*(\t[^}\t]*)"+re2+")\t\}$","gmi");html="";while (match = re.exec(s)) { i++; html=html+"<tr><td>"+match[1].replace(/\t/g, "</td><td>")+"</td></tr>";} document.getElementById("res").innerHTML="<table border=1 cellpadding=4><tr><th>CIP</th><th>Mail</th><th>Date de virement</th><th>Montant</th><th>Vague</th><th>Lien facture</th></tr>"+html+"</table>";document.getElementById("total").value=i;}

</script>
</head>
<body>
<img src="XXX.jpg" height="64"/><br><br>
Recherche <input id="tout"> par <select id="champ"><option value="0">Tous les champs</option><option value="1">CIP</option><option value="2">Email</option></select> <button onclick="ok_onclick()" style="width:72px">OK</button>
<br><br>Shop trouvées : <input id="total" readonly size="5" style="border:none;"/><br>
<div id="res"></div>
<textarea id="source" style="visibility:hidden">


{   IDCLIENT123 email@gmail.com 20/09/2022  50EUR   AMAZON  <a href="https://127.0.0.1">lien</a>    }



</textarea>
</body>
</html>
Thomas H
  • 11
  • 1
  • 1
    Does this answer your question? [How to read data From \*.CSV file using JavaScript?](https://stackoverflow.com/questions/7431268/how-to-read-data-from-csv-file-using-javascript) – Nico Haase Nov 08 '22 at 16:04
  • [This may be of interest](https://web.dev/read-files/). – Ben Aston Nov 08 '22 at 16:34

0 Answers0