javascript - PHP get something from a html file, then pass something back to the original html file -


i new php, suppose, have index.html, , cal.php, in directory.

index.html:

<head>     <script>         java script here used display graphs based on cal.php calculated results     </script> </head> <body>     <form action="cal.php" method="post">         <div class="row x_title">             <div class="col-md-6">                 <h3>dashboard</h3>             </div>             <select class="form-control" id="myfileselect">                 <?php                 echo '<option>choose file</option>';                 foreach (glob('report' . '/*.csv') $file) {                     list($af, $bf) = split("/", $file, 2);                     list($filenam, $extnt) = split(".", $bf, 1);                     echo '<option value="' . $bf . '">' . $filenam . '</option>';                 }                 ?>             </select>         </div>         <input type="submit">     </form> </body> 

cal.php

<?php $row = 1; if (($handle = fopen("test.csv", "r")) !== false) {     while (($data = fgetcsv($handle, 1000, ",")) !== false) {         $num = count($data);         echo "<p> $num fields in line $row: <br /></p>\n";         $row++;         ($c = 0; $c < $num; $c++) {             echo $data[$c] . "<br />\n";         }     }     fclose($handle); } $output /* pass output original html */ /* let's pass php variable $output javascript on original html */ ?> 

i want post form when user hit submit, pass value cal.php, doing calculations in cal.php file, pass variable $output original html's javascript variable.

i'm kind of blank on between how php works html page.

some 1 me? or give me ideas?

using ajax can it. ajax request index.html calling cal.php cal.php should echo result wantand in success function of ajax response.


Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

node.js - Express and Redis - If session exists for this user, don't allow access -