【发布时间】:2022-01-11 19:12:00
【问题描述】:
我在index.php 中有这个 div
<div class="class" id="ScoreResult" style="display:none;">
我在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, "=" );
// the alert works normally
echo '<script> alert("heelo"); </script>';
// this part that trying to show the div doesn't work
echo '<script type="text/JavaScript">
function showtable1()
{
document.getElementById( "ScoreResult").style.display = "block";
}
showtable1();
</script>'
;
echo "<style type=\"text/css\"> #ScoreResult {display:block;}</style>";
}
这是输入的形式和按钮,我不确定我应该进行操作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>
【问题讨论】:
-
表单元素是一个链接,提交表单会导航到表单的
action属性指向的 URL(或该 URL 返回的任何内容)。如果未定义action,则使用页面的当前位置。 -
@Teemu 表单正在运行,功能也在运行,但是这段用于显示 div 的特定代码根本不起作用
-
我什至尝试过 index.php 本身现在也能正常工作
-
表单中的action属性指向
index.php,youtubedata.php与问题有什么关系?
标签: javascript php html css web-applications