Advertisement

03.29.2008 at 11:48AM PDT, ID: 23279736
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.0

Invoke a php function by clicking on a javascript element.

Asked by mipsmedia in PHP Scripting Language, JavaScript

Tags: ,

I'm developing a calendar web app.

When the user clicks on a date on the calendar. (I'm using this calendar - http://www.dynarch.com/projects/calendar/)

I want a database request to be made and update the table of appointments...I have heard that AJAX might be able to do something like that....but I know VERY little about how AJAX works....

here is the code I have so far...

I'm getting alot of errors and the code does not seem to be working...

Any help would be great.
Thanks,
JoshStart Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
<?php
       $startTime = 8;
       $endTime = 20;
       $numApp = 0;
       $theraID = $_POST["theraName"];
       $massID =  $_POST["massID"];  
?>
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
    <head>
    <meta http-equiv="Expires" content="Fri, Jan 01 1900 00:00:00 GMT">
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-cache">
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <meta http-equiv="content-language" content="en">
    <meta name="author" content="">
    <meta http-equiv="Reply-to" content="@.com">
    <meta name="generator" content="PhpED 5.2">
    <meta name="description" content="">
    <meta name="keywords" content="">
    <meta name="creation-date" content="09/20/2007">
    <meta name="revisit-after" content="15 days">
    <title>
        <?php 
            echo "$siteName Book Appointment";
        ?>
    </title>    
    <link rel="stylesheet" type="text/css" href="<?php echo $cssScript ?>calendar-win2k-1.css" /> 
    <script type="text/javascript" src="<?php echo $jsPath ?>common.js"></script> 
    <script type="text/javascript" src="<?php echo $jsPath ?>calendar.js"></script>    
    <script type="text/javascript" src="<?php echo $jsPath ?>lang/calendar-en.js"></script>
    <script type="text/javascript" src="<?php echo $jsPath ?>calendar-setup.js"></script>
 
  
    <script type="text/javascript" language="Javascript" >
     
    </script>
    </head>
    <body>
    <form name="frmBookApp" method="post" action="appWizard.php5?appDone='y'&timedate=''" >
        <div align="center" ><?php echo $err_msg?></div>
        When would you like the appointment for?  
        <div style="position:absolute; margin-top:5em; margin-left: -15em; margin-bottom: 1em;"
             id="myFlatCalendarContainer"></div>
        <br /><br />
        <div style="postition:absolute; "class="heading">Currently <?php echo $numApp ?> appointments booked for <span id="appDate"><?php echo date("m/d/Y");?></span></div>
        <div style=" position:absolute;  margin-top: 1.55em; margin-left: -3em; margin-bottom: 1em;overflow-y:scroll;height:195px;width:250px;border:1px solid black">
        <table width="250px" border="0" cellspacing="0" cellpadding="0">
        <tr width="100%">
          <td width="100%" bgcolor="black">
            <table width="249px" border="0" cellspacing="1" cellpadding="2">
        <?php
        /**
        * @desc     Will return true if there is are no appointments booked 
        *           for that given date and time
        * 
        * @param    $timeValue  the queried time
        * @param    $dateValue  the queried date
        * 
        */
        function notBooked($timeValue, $dateValue, $conn) {
            //pull from database current appointments for $dateValue
            if($conn){
                mysql_selectdb("projects");
                $dateValue = date('Y-m-d',$dateValue);
                $timeValue = date("H:i:00",$timeValue);
                $dateValue += $timeValue;
                //create the sql and run the query
                try{
                    $SQLCmd = "SELECT * FROM appointments WHERE whenDone='$dateValue%' && psin='" . $_SESSION['theraID'] . "'"; 
                    $result = mysql_query($SQLCmd,$conn); 
                    if($result){
                        //app already booked
                        return false;
                    }
                    else {
                        //no appointments on this date.
                        //no nothing        
                    }
                }
                catch (Exception $e){
                    //no appointments on this date.
                    //no nothing 
                }           
            }
            return true;   
        }
        
        /**
        * @desc     Will return true if the time is not past the current time
        * 
        * @param    $timeValue  the queried time
        * 
        */
        function notPast($timeValue) {
            //check to see if current time 
            if($timeValue < date("g:i A")){
                return false;    
            }
            return true;   
        }
        //Dynamically Build the appointment calendar day view.
        for ($i=$startTime;$i<$endTime;$i++){
            echo "<tr bgcolor=\"#FFFFFF\" >";
            echo "<td width=\"30%\">";
            //Insert time here.
            echo date("g:i A", mktime($i,0,0));
            echo "";                
            echo "</td>";
            echo "<td width=\"75%\" ";
            //Insert if appointment (maybe change back color)
            if(notBooked(date("g:i A", mktime($i,0,0)),date("m/d/Y"),$conn) && notPast(date("g:i A", mktime($i,0,0)))) {
                echo "id=\"" . date("g:i A", mktime($i,0,0)) . "\" onclick=\"document.getElementById('updateME').innerText = document.getElementById('appDate').innerText + ' ' + '" . date("g:i A", mktime($i,0,0)) . "';\"";
                echo ">&nbsp;</td>";
            }
            else {
                echo "bgcolor=\"blue\"";
                echo ">Booked</td>"; 
            }
            echo "</tr>"; 
            echo "<tr bgcolor=\"#FFFFFF\" width=\"25%\">";
            echo "<td width=\"30%\">";  
            //Insert time here.
            echo date("g:i A", mktime( $i,30,0));
            echo "";                
            echo "</td>";
            echo "<td width=75%\" "; 
            //Insert if appointment (maybe change back color)
            if(notBooked(date("g:i A", mktime($i,30,0)), date("m/d/Y"),$conn) && notPast(date("g:i A", mktime($i,30,0)))) {  
                echo" id=\"" . date("g:i A", mktime($i,30,0)) . "\" onclick=\"document.getElementById('updateME').innerText = document.getElementById('appDate').innerText + ' ' + '" . date("g:i A", mktime($i,30,0)) . "';\"";
                echo ">&nbsp;</td>"; 
            }
            else {
                echo "bgcolor=\"blue\"";
                echo ">Booked</td>"; 
            }
            echo "</tr>"; 
            }
        ?>
 
        </table>
        </td>
        </tr>
        </table>
        </div>
        <div style="float: left; margin-top: 15em; margin-left: 1em; margin-bottom: 1em;">
        <div class="heading">Confirm your appointment:</div> 
        Name of Massage: <?php echo $_SESSION['massName']?> <input type="button" name="Change" value="Change" class="button" onclick="window.location = 'appWizard.php5';"/> <br />
        Name of Therapist: <?php echo $_SESSION['theraName']?> <input type="button" name="Change" value="Change" class="button" onclick="window.location = 'appWizard.php5?massID=<?php echo $_SESSION['massID'] ?>';"/> <br />
        Appointment Date: <div id="updateME"></div>  <br />
        <input type="submit" name="Continue" value="Continue" class="button" onclick="doSubmit();"/>
        </div>
    </form>
    <script type="text/javascript">
        function doSubmit() {
            var action = "appWizard.php5?appDone='y'";
            var divUpdateME = document.getElementById("updateME");
            action += "&timedate='" + escape(divUpdateME.innerHTML) + "'";
            document.frmBookApp.action = action;
            document.frmBookApp.submit();
        }
        function dateStatus(date) {
            var noLongerValid = new Date();
            noLongerValid.setDate(noLongerValid.getDate()-1)
 
            if (date.getTime() < noLongerValid.getTime())
            return true; // true says "disable"
            else
            return false; // leave other dates enabled
        
        }
    
        function dateChanged(calendar) {
            // Beware that this function is called even if the end-user only
            // changed the month/year.  In order to determine if a date was
            // clicked you can use the dateClicked property of the calendar:
            if (calendar.dateClicked) {
                // OK, a date was clicked, redirect to /yyyy/mm/dd/index.php
              var y = calendar.date.getFullYear();
              var m = calendar.date.getMonth();     // integer, 0..11
              var d = calendar.date.getDate();      // integer, 1..31
              if((m+1) < 10) {
              m = "0" + (m+1);
              }
              if(d < 10) {
              d = "0" + d;
              }
              returnObjById("appdate").innerHTML = m + "/" + d + "/" + y;
            }
          };
 
  Calendar.setup(
    {
      dateStatusFunc    : dateStatus,
      flat              : "myFlatCalendarContainer", // ID of the parent element
      flatCallback      : dateChanged           // our callback function
    }
  );
 
 
</script>
 
    </body>
</html>
[+][-]03.29.2008 at 12:04PM PDT, ID: 21237722

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.29.2008 at 12:21PM PDT, ID: 21237780

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: PHP Scripting Language, JavaScript
Tags: PHP, IE 6
Sign Up Now!
Solution Provided By: almilyo
Participating Experts: 2
Solution Grade: A
 
 
[+][-]03.29.2008 at 12:55PM PDT, ID: 21237863

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.29.2008 at 01:19PM PDT, ID: 21237939

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]03.29.2008 at 01:31PM PDT, ID: 21237992

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.29.2008 at 01:50PM PDT, ID: 21238078

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628