首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在单击另一个php文件中的提交按钮后显示html隐藏的div

如何在单击另一个php文件中的提交按钮后显示html隐藏的div
EN

Stack Overflow用户
提问于 2021-12-06 10:11:36
回答 1查看 377关注 0票数 0

我在seosystem/index.php有这个div

代码语言:javascript
复制
<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来显示数据

代码语言:javascript
复制
 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

代码语言:javascript
复制
 <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>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-12-07 11:20:39

有两个无效的变量。TITLE & YTCODE.我不知道你是怎么得到这些的。

但是,只有在响应有效时才显示DIV,这是代码;

代码语言:javascript
复制
youtube.php
代码语言:javascript
复制
<?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>' ;  */

}
代码语言:javascript
复制
index.php
代码语言:javascript
复制
<?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 } ?>
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70243803

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档