proggR Posted January 22, 2009 Share Posted January 22, 2009 So I wasn't really paying attention in my JS class the other day but I managed to copy the code on the board. I basically have a 12 month calendar on the left of the screen and I have an hour-by-hour break down of an individual day on the right. When you click a day it is supposed to update the header of the day table to change the date. We don't have to have any information in the hours of the day because I think he's going to get us to script that to pull from a server at a later time. If someone could explain how to change data post-rendering it would be helpful. I know its something easy and I'm just farting really loud in my brain. The code snippet he gave is: <td id="schedule-date"></td> **inside handler** var scheduleCell=document.getElementByID("schedule-date"); scheduleCell.innerHTML(month+" "+day); For some reason its not liking when my onclick passes more than just one variable so for right now it only passes the day to a function. I have an alert in the function display the day and that works. Its not, however, displaying the day in the contents of the table. Here are those sections of my code: //the script that makes the calendar for(ctr=lastDay;ctr<=7;ctr++){ document.write("<td onclick=\"displayDat("+day+");\">"+day+"</td>"); day++; } //just a portion, this would only do a week, assuming lastDay was 1 // the function that gets called function displayDat(day){ alert(day); var scheduleCell=document.getElementByID("schedule-date"); scheduleCell.innerHTML(day); } //the function that makes the day table function displayAppt(){ var hour; document.write("<table border='1'><tr><td id=\"schedule-date\" colspan='2' rowspan='1'></td></tr>"); for (hour=8;hour<=18;hour++){ document.write("<tr><td width='20'>"+hour+":00</td><td></td></tr>"); document.write("<tr><td width='20'>"+hour+":30</td><td></td></tr>"); } document.write("</table>"); } I know its not your homework and clearly I'm doing something wrong, but any help would be great. Quote Link to comment Share on other sites More sharing options...
Psycho Posted January 22, 2009 Share Posted January 22, 2009 I've never seen a value passed to innerHTML in that manner (i.e. within parens). Try this: scheduleCell.innerHTML = month+" "+day; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.