I am a complete beginner to JavaScript and other web technologies and am currently trying to append the data the user enters into the input form to a CSV file.
This is what I have tried so far:
<form id="form">
Type the latitude of the crime: <input type="text" name="latitude"><br>
Type the longitude of the crime: <input type="text" name="latitude"><br>
Enter the date in which the incident took place: <input type="text" name="latitude"><br>
<input type="button" value="submit" id="submit-btn" onclick="submitCrime">
</form>
<script>
//Clear form once submitted
function clearForm(){
document.getElementById("form").reset();
}
function submitCrime() {
var formData = $("form").serializeArray();
let csv = "data:/Users/duvalbalogun-palmer/Desktop/VGIS/php-shit/assault.csv;charset=utf-8,"; // accept data as CSV
formData.forEach(function(item) {
csv += item.value + ";"; // concat form value on csv var and add ; to create columns (you can change to , if want)
});
var encodedUri = encodeURI(csv);
clearForm();
</script>
</body>
</head>
Whenever clicking on the "submit" button, nothing happens. Any help would greatly be appreciated!