【发布时间】:2013-08-29 04:16:41
【问题描述】:
嘿,我正在制作活动日历。日历中的每个事件都由一个按钮表示,当我单击它时,我想传递一些变量。现在它只会让我传递 $id 并且由于某种原因我的两个字符串变量($description 和 $title)都不能传递
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});
};
我试过用逗号分隔变量,但没有成功。
提前致谢。
【问题讨论】:
-
它们应该用逗号分隔,并注意引号
-
试试
.id.','.$description.','.$title. -
另外,如果值是字符串,你需要在它们周围加上引号,所以它应该是
.\'$id\'.','.\'$description\'.','.\'$title\'.
标签: php javascript jquery html jquery-ui-dialog