0

I have a .csv list with names separated with semicolons: John Smith;Ola Nordmann; etc, and I was wondering how I can read the file and then print out the names like this:

<select>
  <option> John Smith
  <option> Ola Nordmann
  <option> etc
<\select>

It’s a local csv file and I have to use vanilla JavaScript.

My thought was that I could use a for-loop and somehow count the semicolons to determine the for-loops length, but I don’t really know how to do that. Nor do I know how get the data “out” of the file and “into” the option list.

3
  • Use can use split(';') on the string to get an array of names. As to how to read a file try this stackoverflow.com/a/12372727 if you if will supplying the file from browser Commented Jan 26, 2020 at 3:14
  • I assume you mean "csv", as in "character-separated value"? CVS is either a pharmacy or a source-control system, depending on context. Commented Jan 26, 2020 at 3:27
  • @Viney what if it's from a local file? Commented Jan 26, 2020 at 14:53

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.