You can use HTMLElement.dataset to read/write custom data attributes. An example app is HERE. You can also work with localStorage directly, than the unique ID would be date.
In order to show text/data into calendar cell, you need a placeholder. In my example each table cell is in this format:
<td>
<div data-date="6-1-2015" class="box">
<span class="day">6</span>
<span class="text"></span> <!-- this is a placeholder -->
</div>
</td>
This way it is easy to find clickable cells:
// Select clickable cells
var cells = document.querySelectorAll('.box');
than to bind click events (to open modal window):
// Bind clickable cells
for (var i = 0; i < cells.length; i++) {
cells[i].addEventListener('click', function(e) {
var thisCell = this;
var thisDate = thisCell.dataset.date;
var thisEvent = thisCell.dataset.event;
var thisParticipants = thisCell.dataset.participants;
var thisDescription = thisCell.dataset.description;
date.innerHTML = thisDate;
event.value = thisEvent || '';
participants.value = thisParticipants || '';
description.value = thisDescription || '';
modal.style.display = 'block';
});
};
Saving data is piece of cake:
// Bind save button
submit.addEventListener('click', function(e) {
var thisDate = date.innerHTML;
var thisEvent = event.value;
var thisParticipants = participants.value;
var thisDescription = description.value;
var thisCell = document.querySelector('[data-date="' + thisDate + '"]');
// Assign data to table cell
thisCell.dataset.event = thisEvent;
thisCell.dataset.participants = thisParticipants;
thisCell.dataset.description = thisDescription;
// Show on screen
var textField = thisCell.querySelector('.text'); //-- This is our container
textField.innerHTML = '\
<span class="eve">' + thisEvent + '</span>\
<span class="par">' + thisParticipants + '</span>\
<span class="des">' + thisDescription + '</span>\
';
modal.style.display = 'none';
});
and after filling data, table cell looks like this:
<td>
<div data-date="6-1-2015" class="box" data-event="Event Title" data-participants="John, Robert" data-description="Football">
<span class="day">6</span>
<span class="text">
<span class="eve">Event Title</span>
<span class="par">John, Robert</span>
<span class="des">Football</span>
</span>
</div>
</td>
For more info, please take a look at Fiddle, code is huge to paste it here.