I am working on a web application where users can copy their excel data (multiple rows with 2 columns) onto a website's text area. When clicking submit button on the same page, it will covert the excel data to JSON, displays the JSON in a different text area on the same web page.
I already got a HTML page going, just not certain how to write the convert code. (Code below)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset = "utf-8" />
<title>Convert</title>
</head>
<body>
<h1>Convert Table Data (2 Columns) To JSON</h1>
<button onclick="convert()">Convert to JSON</button>
<br><br>
<textarea id="inputText" rows="50" cols="100"></textarea>
<textarea id="outputText" rows="50" cols="100" readonly></textarea>
<script>
var textarea = document.getElementById("inputText");
var textarea2 = document.getElementById("outputText");
function convert() {
// textarea2.value = textarea.value.convertToJSON......
}
</script>
</body>
</html>
Here is what the excel data will look like when copied and pasted into a text area:
Amy apples
Betty oranges
Cathy watermelon
Daisy bananas
Edward pears
Fiona grapes
Expected results to be displayed on different text area after submit:
{
"Amy" : "apples",
"Betty" : "oranges",
"Cathy" : "watermelon",
"Daisy" : "bananas",
"Edward" : "pears",
"Fiona" : "grapes"
}