Php 将值传递给对话框模式
我使用多个按钮(动态)打开一个div:Php 将值传递给对话框模式,php,jquery,Php,Jquery,我使用多个按钮(动态)打开一个div: <div class="dialog" title="Player"> <p>YouTube Player here</p> </div> 这里是YouTube播放器 在标题处,我使用: $(函数(){ $(“.dialog”).dialog({ 自动打开:错误, 展示:{ 效果:“盲”, 持续时间:1000 }, 隐藏:{ 效果:“盲”, 持续时间:1000 } }); $(“.open
<div class="dialog" title="Player">
<p>YouTube Player here</p>
</div>
这里是YouTube播放器
在标题处,我使用:
$(函数(){
$(“.dialog”).dialog({
自动打开:错误,
展示:{
效果:“盲”,
持续时间:1000
},
隐藏:{
效果:“盲”,
持续时间:1000
}
});
$(“.opener”)。单击(函数(){
$(“.dialog”).dialog(“打开”);
});
});
我使用的按钮如下:
foreach($ytObject->RKT\u requestResult->entry as$video){
return=$YObject->parseVideoRow($video);
$delimiter=“**”;
$VideoContent=explode($delimiter,$return);
如果($count%2==0){
回声“;
呼应“玩”;
回声“;
echo$VideoContent['6'];
回声“;
}否则{
回声“;
呼应“玩”;
回声“;
echo$VideoContent['6'];
回声“;
}
$count++;
}
我想获取
$VideoContent['0']
的值作为
的弹出内容,以便我可以将YouTube视频直接放到模式上。使用以下代码获取值:
$(".opener").click(function() {
var video = $(this).siblings("a").attr("href");
alert(video); //here video will have the value of $VideoContent['0']
$(".dialog").dialog("open");
});
我已经做到了。我使用的函数是:
<script>
$(function() {
$(".dialog").dialog({
width: 450,
autoOpen: false,
show: {
effect: "blind",
duration: 1000
},
hide: {
effect: "blind",
duration: 1000
}
});
$(".opener").click(function() {
var video = $(this).siblings("a").attr("href");
var VideoId = video.replace('http://www.youtube.com/watch?v=', '');
var VideoId = VideoId.replace('&feature=youtube_gdata', '');
var youtube = "<embed width=\"420\" height=\"345\" src=\"http://www.youtube.com/v/" + VideoId + "\" type=\"application/x-shockwave-flash\"> </embed>";
$(".dialog").dialog("open").html(youtube);
});
});
</script>
$(函数(){
$(“.dialog”).dialog({
宽度:450,
自动打开:错误,
展示:{
效果:“盲”,
持续时间:1000
},
隐藏:{
效果:“盲”,
持续时间:1000
}
});
$(“.opener”)。单击(函数(){
var video=$(this.sibbines(“a”).attr(“href”);
var VideoId=video.replace('http://www.youtube.com/watch?v=', '');
var VideoId=VideoId.replace(“&feature=youtube_gdata”,”);
var=”;
$(“.dialog”).dialog(“open”).html(youtube);
});
});
打开它的链接/按钮是<button class="opener btn" class="btn"><img src="img/Play-icon.png" alt="play" /> Play</button>
echo "<a href = \"" . $VideoContent['0'] . "\" class=\"\"></a> ";
播放
回声“;
可能有点愚蠢或棘手:p但工作正常^_^
实际上,按钮是循环的。因此,我使用按钮显示模式,并使用空白href获取值。就这样。:) 您是否尝试使用嵌入标记而不是标记。我假设$VideoContent['0']有视频的URL,可以应用于嵌入tag@AnteOmnio,这个链接可能会让你有所了解,看看@Chirag Yes
$VideoContent['0']
包含URL。但是我如何将其嵌入按钮并使用它呢?我不熟悉JQuery。这就是为什么我不确定在哪里以及如何嵌入它。你能只提供你的代码的HTML吗?
<script>
$(function() {
$(".dialog").dialog({
width: 450,
autoOpen: false,
show: {
effect: "blind",
duration: 1000
},
hide: {
effect: "blind",
duration: 1000
}
});
$(".opener").click(function() {
var video = $(this).siblings("a").attr("href");
var VideoId = video.replace('http://www.youtube.com/watch?v=', '');
var VideoId = VideoId.replace('&feature=youtube_gdata', '');
var youtube = "<embed width=\"420\" height=\"345\" src=\"http://www.youtube.com/v/" + VideoId + "\" type=\"application/x-shockwave-flash\"> </embed>";
$(".dialog").dialog("open").html(youtube);
});
});
</script>
<button class="opener btn" class="btn"><img src="img/Play-icon.png" alt="play" /> Play</button>
echo "<a href = \"" . $VideoContent['0'] . "\" class=\"\"></a> ";