作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
">Video1 Video2 Video3 最佳答案 我建-6ren">
我仍然是新手,我真的很难过。选择第一个复选框后,如何将嵌入的youtube视频回显到页面?请帮忙。谢谢。
<form action="" method="post">
<label><input type="checkbox" name="check_list[]" value="<?php echo "<iframe width=\"640\" height=\"360\" src=\"http://www.youtube.com/embed/TnxUOdAhAdk\" frameborder=\"0\" allowfullscreen></iframe>"; ?>">Video1</label>
<label><input type="checkbox" name="check_list[]" value="value 2">Video2</label>
<label><input type="checkbox" name="check_list[]" value="value 3">Video3</label>
<input type="submit" />
</form>
<?php
if(!empty($_POST['check_list'])) {
foreach($_POST['check_list'] as $check) {
echo $check;
}
}
?>
最佳答案
我建议您使用javascript / jquery而不是php,因为您已经知道YouTube链接。 This link will give you more info about this。
无论如何,这里是一个可以帮助您的php代码:
<html>
<head>
</head>
<body>
<form action='index.php' method='post'>
<input type='checkbox' name='video1' value='true'/>Show Video1
<br/>
<input type='checkbox' name='video2' value='true'/>Show Video2
<br/>
<input type='checkbox' name='video3' value='true'/>Show Video3
<br/>
<input type='submit' value='Show Videos'/>
</form>
<?php
if (isset($_POST['video1'])) {
echo "<iframe width=\"640\" height=\"360\" src=\"http://www.youtube.com/embed/TnxUOdAhAdk\" frameborder=\"0\" allowfullscreen></iframe>";
echo "<br/>";
echo "<br/>";
}
if (isset($_POST['video2'])) {
echo "<iframe width=\"640\" height=\"360\" src=\"http://www.youtube.com/embed/2mKxsC2oi5s\" frameborder=\"0\" allowfullscreen></iframe>";
echo "<br/>";
echo "<br/>";
}
if (isset($_POST['video3'])) {
echo "<iframe width=\"640\" height=\"360\" src=\"http://www.youtube.com/embed/tC2fjzWIM-Y\" frameborder=\"0\" allowfullscreen></iframe>";
echo "<br/>";
echo "<br/>";
}
?>
</body>
</html>
关于iframe - 回显iframe内部值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17417013/
我是一名优秀的程序员,十分优秀!