mellis95 Posted January 28, 2010 Share Posted January 28, 2010 I am fairly new to Javascript and AJAX.... I am working on a medical scheduling application where I would like to populate a schedule grid/table with appointment information for multiple physicians. The output should look like: TIMEPHYSICIAN 1PHYSICIAN 2PHYSICIAN 3 8:00 amPatient 1Patient 2Patient 3 8:15 am[/td][td]Patient 2(MEETING) In MySQL, I have the following table: CREATE TABLE `tbl_schedule` ( `sid` int(20) NOT NULL AUTO_INCREMENT, `physician_id` int(11) DEFAULT NULL, `patient_id` int(11) DEFAULT NULL, `s_date` date DEFAULT '0000-00-00', `s_time` varchar(4) DEFAULT NULL, PRIMARY KEY (`sid`) ) ENGINE=MyISAM AUTO_INCREMENT=4 DEFAULT CHARSET=latin1 Basically, I need the schedule grid to ALWAYS show all time slots (in 15 min increments), but only display a patient name in the correct cell for time/physician. My thought is to accomplish this by creating the grid with javascript and naming EVERY cell with something like "physician_id+time" and then display the appropriate patient where physician_id+time(from mysql query) matches the id of the DOM element.... But I don't know how to go about doing that. I can create the table and properly name the elements, but I am not sure how to tell it to only display where everything matches.. Is it even possible? Am I going about it all wrong? Thanks for the help. Matt Quote Link to comment Share on other sites More sharing options...
jug Posted January 28, 2010 Share Posted January 28, 2010 Hi, I would achieve this a different way. I would use the 'responseText' method of the xmlHttpRequest and generate the HTML output in the PHP/ASP script file. From here, using the 'repsonseText' method in the JavaScript file, you can retrieve the generated HTML code from the script and use DOM to add to the innerHTML of any object. Hope this helps jug Quote Link to comment Share on other sites More sharing options...
kickstart Posted January 30, 2010 Share Posted January 30, 2010 Hi Do you need this to update constantly? To me your initial description sounds like an SQL issue. Have a table of physicians and a table of time slots and cross join them together, and left join that with the table above. You can then use Ajax to update the slots when selected if you want. All the best Keith 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.