我在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>发布于 2021-12-07 11:20:39
有两个无效的变量。TITLE & YTCODE.我不知道你是怎么得到这些的。
但是,只有在响应有效时才显示DIV,这是代码;
youtube.php<?php
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, "=" );
$verified_success = "yes"; // This is the conditional variable.
/* echo '<script type="text/javascript">',
'showtable(){
document.getElementById(<?php echo "ScoreResult" ;?>).style.display = "block";
}',
'</script>' ; */
}index.php<?php
// Stop Irrelevant Warning Signs From Showing such as invalid variables
error_reporting(E_ERROR | E_PARSE);
include("youtube.php");
?>
<?php
if ($verified_success == NULL) {
?>
<form class="d-flex justify-content-center " method="GET" action="">
<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>
<?php } ?>
<?php
if ($verified_success != NULL) {
?>
<div class="class" id="ScoreResult">
<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>
<?php } ?>https://stackoverflow.com/questions/70243803
复制相似问题