">Video1 Video2 Video3 最佳答案 我建-6ren">
gpt4 book ai didi

iframe - 回显iframe内部值

转载 作者:行者123 更新时间:2023-12-03 06:33:42 24 4
gpt4 key购买 nike

我仍然是新手,我真的很难过。选择第一个复选框后,如何将嵌入的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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com