嘿,我正在製作活動日曆。日曆中的每個事件都由一個按鈕來表示,當我點擊它時,我想通過一些變量。現在只會讓我傳遞的$ id並由於某種原因,既不是我兩個字符串變量($說明和$標題)onClick參數中的字符串
代碼爲的onClick按鈕和foreach循環在那裏我得到的信息:
$event_day = $day_num . '.' . $month . '.' . $year;
foreach ($eventArray as $currentEvent) {
$result = $string->convert_timestamp_to_string($currentEvent['start_date']);
if ($result === $event_day) {
$id = $currentEvent['id'];
$title = $currentEvent['title'];
$description = $currentEvent['description'];
$pageContent .= '<input type="button" class="event" onClick="showDialog('.$id. $description. $title.')" value="' . $title . '"/>';
}
}
這裏是通過了的應該創建基於變量對話的功能
var showDialog = function(id, description, title) {
$("#dialog-modal").dialog({title:title});
};
我試過用逗號分開變量,沒有運氣。
在此先感謝。
他們應該是逗號分隔,並觀看引號 – 2013-08-28 20:11:52
嘗試'.ID '' $說明 '' $ title.' –
。另外如果這些值是字符串,你需要在它們周圍加引號,所以它應該是'。\'$ id \'。','。'$ description \'。','。'$ title \'。 –