【发布时间】:2022-01-11 13:30:03
【问题描述】:
我在seosystem/index.php 中有这个 div
<div class="class" id="ScoreResult" style="display:none;">
<div class="row border border-5 " style="background:whitesmoke;">
<div class=" col toast w-20 z-depth-5 shadow-lg p-3 mb-5 bg-white rounded show w-100">
<div class="toast-header">
<strong class="me-auto">Description</strong>
<!-- <button type="button" class="btn-close" data-bs-dismiss="toast"></button> !-->
</div>
<div class="toast-body ">
<div class="progress" style="height:20px; width:200px;">
<div class="progress-bar bg-success" style="width:33.33%"></div>
<div class="progress-bar bg-warning" style="width:33.33%"> </div>
<div class="progress-bar bg-danger" style="width:33.33%"> </div>
</div>
<p>10/10</p>
</div>
</div>
<div class="col-sm border border-5 col-xxl mx-auto">
<h4><?php echo "Title: " . $title; ?></h4>
<?php echo "<iframe style=\"background-color:whitesmoke;\" position=\"center\"allow=\"accelerometer\"; gyroscope; width=\"100%\" height=\"315\" src=\"http://www.youtube.com/embed/$ytcode\" frameborder=\"0\" allowfullscreen></iframe></div>";
?>
</div>
</div>
我在seosystem/controller/youtubedata.php 有这个功能,我试过用 Js 没用
所以我希望当用户提交按钮时,它会显示 div 来显示数据
if($_SERVER['REQUEST_METHOD'] == "GET" && isset($_GET['url']) && isset($_GET['submit'])){
/* echo "</br >" ;
echo $input_Url_data . "Button clicked" ; */
$id_position = strstr($input_Url_data,"=");
$id_position = trim($id_position, "=" );
echo '<script type="text/javascript">',
'showtable(){
document.getElementById(<?php echo "ScoreResult" ;?>).style.display = "block";
}',
'</script>' ;
}
这是输入和按钮的形式,我不确定我应该执行操作index.php 还是seosystem/controller/youtubedata.php
<form class="d-flex justify-content-center " method="GET" action="index.php">
<div class="input-group ">
<input type="text" class="form-control" name="url" placeholder="Enter Youtube Video URL" aria-label="Example text with button addon" aria-describedby="button-addon1">
<input class="btn" value="Analyze" name="submit" type="submit" id="button-addon1"></input>
</div>
</form>
【问题讨论】:
-
在 JS 中你定义了一个函数,但你不运行它。
-
我以为它会被自动调用我编辑它仍然无法工作
if($_SERVER['REQUEST_METHOD'] == "GET" && isset($_GET['url']) && isset($_GET['submit'])){ /* echo "</br >" ; echo $input_Url_data . "Button clicked" ; */ $id_position = strstr($input_Url_data,"="); $id_position = trim($id_position, "=" ); echo '<script> showtable(); </script>'; } -
并在
seosystem/controller/youtubedata.php<html> <head> <script type="text/javascript"> function showtable() { document.getElementById( "ScoreResult").style.display = "block"; } </script> </head> <body> <script src="..\bootstrap\scriptname.js"></script> </body> </html>的第一部分添加了这部分 -
我执行了 js 示例,它可以工作,你认为该函数无法读取 div 的 id,因为它来自另一个文件吗?
标签: javascript php html css