I have in file JSON data which I'm displaying on UI and a form from which user can update data. How can I update the JSON data with the values entered by the user on the form and render it on the UI after submit.
//Html code
<div id="myModal" class="modal">
<!-- Add movie Modal content -->
<div class="modal-content">
<span class="close" onclick="closeModal()">×</span>
<form name="submitmovie" onsubmit="addMov()">
<label>Enter Movie Name</label>
<input type="text" name="movie-name" id="mnane" placeholder="enter movie name">
<label>Year</label>
<input type ="number" name="movie-year" id="myear" placeholder="movie-year">
<label>Poster Url</label>
<input type ="url" name="movie-poster" id="mposter" placeholder="movie-poster-url">
<button class="addMovie" type = "submit">Submit</button>
</form>
</div>
</div>
<script type="text/javascript">
function addMov(){
var name = document.getElementById("mnane").value;
var year = document.getElementById("myear").value;
var url = document.getElementById("mposter").value;
console.log(name,year,url);
// add();
movieList.push({
"name":name,
"year":year,
"url":url
});
renderMovieCards();
}
</script>