I recently sought help with JavaScript on this platform. I needed a script to parse a CSV file and display it as HTML.
Fortunately, someone provided me with a lot of assistance. However, the issue is that the output is in the form of a single row table. The rows in the CSV file do not have a fixed number of columns or data, resulting in varying lengths for each row.
I have been attempting to use if statements to specifically extract data such as 'Last name' or 'known for' in order to organize the results.
What would be the most effective approach for this? I plan to style the output data so I believe using div IDs would be more suitable than tables. Additionally, where should I make modifications in the code (bearing in mind my limited knowledge in JavaScript)?
The if statement I tried (probably incorrect):
function firstName($container){
var firstN = $container;
var n = firstN.includes("First Name");
if (n != 0){
document.getElementById("first_name").innerHTML="First name = ";
return;
}
}
Main block of code (CSV file can be accessed at ):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="jquery-1.12.3.min.js" type="text/javascript">
</script>
<title>Untitled Document</title>
<script type="text/javascript">
// Some JavaScript functions here...
</script>
<style type="text/css">
body {
font-family: arial, helvetica, sans-serif;
font-weight: normal;
font-size: 13px;
color: #000;
text-align: left;
margin: 3px 0px;
}
#wrap {
padding: 20px;
}
#wrap table {
border: solid 1px;
border-collapse: collapse;
background-color: aliceblue;
height:400px;
width:100%;
}
#first_name {
height:200px;
width:200px;
background-color:#0C0;
}
</style>
</head>
<body>
<button onclick="myFunction()">Click me</button>
<div id="wrap"></div>
<div id="first_name">
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
</body>
</html>
Thank you for your help!