I’m coding a neat calendar feature for my friend. He has a table, and he wants a list of events to pop up corresponding to the day (or cell) that was clicked. For example, if he clicked the cell that was marked with 3 for the third day of the month, something would pop up listing events for that day.
I’ve gotten far. Here’s my javascript:
function calendar() {
var items = calendar.arguments.length;
for(i = 0;i < items; i++){
document.getElementById('popupdiv').innerHTML += "<li>"+calendar.arguments[i]+"</li>";
}
document.getElementById('popup').style.display="block";
document.getElementById('hide').style.display="block";
}
This actually works. When the function calendar() is called, the parameters/arguments will become the events, and they will be listed as <li>s.
Anyways, I wanted to have some sort of way for him to mark more important events in red font. I was thinking of doing this by retrieving the first three letters of each argument, and if they were equal to the string “red”, to make the text red (and to also remove that part of the argument so that it doesn’t display in the actual popup).
Is there an easier way to do this?
Your events need more information. In addition to the event name, add a class option. Pass a set of event items, perhaps something like this:
This requires knowledge of arrays, though. To do exactly what you asked about, try this:
To strip the “red” from the item name: