Currently I’m using Netbeans to create a webpage. The code is listed below, and after a button is pushed, reads a csv file and displays the text file in one row of a table. The CSV file has 50 lines of data, and breaks between each line.
What I want to do, is rather than have the entire file contents in one row, for each line of the file to be in its own row.
I’m completely new to Jquery/Javascript and really not sure how to do this, if its even possible or whether I should be doing something completely different.
I dont necessarily need to stick to what I have below, but I’m stuck with doing this in either Javascript, HTML, jquery or json, and this is just what I have come up with so far that works.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="js/jquery-1.4.2.js"></script>
<script type="text/javascript" src="js/jquery.ui.core.js"></script>
<script type="text/javascript" src="js/jquery.ui.widget.js"></script>
<script type="text/javascript" src="js/jquery.ui.accordion.js"></script>
<script type="text/javascript">
function contentDisp()
{
$.ajax({
url : "file.csv",
success : function (data) {
$("#contentArea").html(data);
}
});
}
</script>
</head>
<body>
<table width="100%" border=0>
<tr>
<td> </td>
<td><input type="button" value="View File" onClick="contentDisp();"></td></tr>
<tr>
<td> </td><td>
<textarea id="contentArea" rows="40" cols="60"></textarea></td></tr>
</table>
</body>
</html>
If I understand correctly it sounds like you want this:
This will replace newlines with the html tag equivalent.