I have this div in index.php
<div class="class" id="ScoreResult" style="display:none;">
and i have this function in seosystem/controller/youtubedata.php
i tried using Js it didn't work so i want when the user submit the button it shows the div to display the data
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>";
}
This the form of the input and the button i'm not sure should i make the action index.php
or 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>
My Answer:
It looks like you are trying to show a hidden div with id "ScoreResult" after the user submits the form. However, the code you provided is in the PHP file, and you are trying to use JavaScript to show the div.
To achieve this, you can move the JavaScript code to the index.php file where the HTML form is located. You can add the JavaScript function to the index.php file and call it after the form is submitted.
Here is an example of how you can modify your code:
1. Move the JavaScript function to the index.php file:
html
2. Update the form action to point to the youtubedata.php file:
html
3. In the youtubedata.php file, after processing the form data, you can redirect back to the index.php file where the JavaScript function will be called to show the hidden div:
php
header("Location: index.php");
exit();
By following these steps, you should be able to show the hidden div after the user submits the form.
Rate this post
5 of 5 based on 9090 votesComments