Najla August Najla August - 5 months ago 20
Javascript Question

PHP code to show a hidden button

I have a page with two buttons

<input type="submit" value="Start Analysis" name="StartAnalysis">
<input type="submit" value="Download Results" name="DownloadResults">


When the page loads, I hide the "DownloadResults" button by default using jQuery's hide method.

After the user selects some input fields and submits the form using "StartAnalysis" I do some computation inside my PHP code. At the end of the computation I need to show user the "DownloadResults" button. How can I show it using PHP?

Thanks in advance!

Edited to include my HTML code (simplified)

<?php
// START ANALYSIS START
if ( isset( $_POST['StartAnalysis'] ) ) {
// Do processing here

// Need help with this: I want Download Results Button to APPEAR so user can click it


}
// START ANALYSIS END
?>

<html>
<script>
// DownloadResults button is hidden by default
$(document).ready(function () {
$('[name="DownloadResults"]').hide();
});

</script>
</head>
<body>
<form enctype="multipart/form-data" name="myForm" method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<!-- Lots of INPUT FIELDS HERE -->

<input type="submit" value="Start Analysis" name="StartAnalysis">
<input type="submit" value="Download Results" name="DownloadResults">
</form>
</body>
</html>

Answer

if i understand correctly u want the button to be shown after form submit and you want to do it with PHP.maybe you can do it this way

first u must add a css for hidden and show.

.hidden{
    visibility="hidden";
}
.show{
    visibility="visible";
}

then in your php script u do it this way

if (isset($_POST['StartAnalysis'])) {
    # code...
    $class = 'show';
} else {
    $class = 'hidden';
}

<input type="submit" value="Start Analysis" name="StartAnalysis">  
<input type="submit" class="<?php echo $class; ?>" value="Download Results" name="DownloadResults">

this way you can hide and unhide with PHP. the button will be show on $_POST['StartAnalysis']