2014-06-12 49 views
0

我有一個日曆控件,它在Page_Load上填充了事件。當用戶點擊某個單元格時,我想查找該單元格中的事件,然後用該信息填充文本區域。在單元格單擊時查找事件Javascript

當點擊一個單元格時,我可以獲得單擊事件,但我不知道如何獲取事件並在Javascript中的文本區域中顯示。

<DayPilot:DayPilotMonth CssClassPrefix="bsimplexcalender" 
    OnCommand="calender_control_Command" 
    ContextMenuID="menu" 
    EventRightClickHandling="ContextMenu" 
    EventRightClickJavaScript="select(e)" 
    BubbleID="DayPilotBubble1" 
    ClientObjectName="dpm" 
    runat="server" 
    ID="calender_control" 
    Theme="bsimplexcalender" 
    HeightSpec="Auto" Height="0" 
    MinCellHeight="63" 
    DataStartField="start" 
    DataEndField="end" 
    DataTextField="name" 
    DataValueField="id" 
    OnBeforeEventRender="calender_control_BeforeEventRender" 
    TimeRangeSelectedHandling="JavaScript" 
    TimeRangeSelectedJavaScript="''THIS IS THE CLICK EVENT I NEED TO FIND EVENT AND DISPLAY HERE" /> 
+0

您必須從數據庫中獲取它... – csanonymus

+0

不熟悉DayPilot,但如果它是您的單擊事件,則可以在該事件中編寫代碼以填充該文本區域。如果它需要更加動態化,那麼應該能夠使用內聯asp.net將變量放在帽子的位置。 – RandomUs1r

+0

@csanonymus它在頁面加載時填充,但我不想回到服務器端來獲取事件。 –

回答

0

此代碼可以幫助:

對於JavaScript:

function loadCalendarEvent(day) { //call this function when table cell is clicked 
//in var day pass the day clicked 
      var xmlhttp; 
      xmlhttp = new XMLHttpRequest(); 

      xmlhttp.onreadystatechange = function() { 
       if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { 
        //just received the answer from server so do something with it here 
       } 

      } 
      var url; //link to php file 
      xmlhttp.open("POST", url, true); 
      xmlhttp.setRequestHeader("Content-Type", "text/json"); //change Content-Type to what you need 
      xmlhttp.send(day); 
     } 

對於PHP:

<?php 
$ClientData = file_get_contents('php://input'); //day variable is stored here 
//query database for event and save it to some variable 
echo $thatVariable; 
?> 

如果你要我解釋更多,留下評論...

相關問題