Can't get on-the-fly select box to work

Can't get on-the-fly select box to work

If you look at source code produced in web developer tools you see the following, however, it is all in one long string. It never shows up on the screen. Don't know how to fix. Help.


 
<h2>Pick A Database to Restore.</h2> 

<form id='frm1' action='' method='post'>
<select id='mySelect' name='DBase'>

<option value=''>
Select...</option>
<option value='1'>
2020Oct14-14:40:24_accounts.sql</option>
<option value='2'>
2020Oct16-09:36:26_accounts.sql</option>
<option value='3'>2020Sep18-13:31:43_accounts.sql</option>
<option value='4'>2020Oct13-13:17:01_accounts.sql</option>
<option value='5'>2020Oct13-13:16:03_accounts.sql</option>
<option value='6'>
2020Oct13-13:38:05_accounts.sql</option>
<select>

<input type='submit' name='submit' value='Get DataBase' >
</form>





  1. <?php

    // restoreBackup.php  pick a database to restore into MySql ...

    include './include/myPhpFunctions.inc';

    error_reporting(-1);
    ini_set("display_errors", true);

       $hostname = "localhost";
       $database = "accounts";
       $username = "rick";
       $passwd = "pwd";
       $row=array();
        
    $directory='./bakups';
    $pickFrom=$pickFile=array();
    $selected='';

    //echo getcwd(); exit();

    // Open the directory, and read its contents
    if (is_dir($directory)){
      if ($fh = opendir($directory)){
        while (($file = readdir($fh)) !== false){
            if($file=="." || $file=="..") {continue;}
            //echo $file;
            $pickFile[]=$file;
        }
        closedir($fh);
      }
    }

    //  ==================================================================================
    //  Need function here to abort and go back to index.html if no databases in bakup file
    //  ===================================================================================

    ?>
    <!DOCTYPE html >

    <html>
        <head>
            <title>restoreBakup.php 15Oct2020 </title>
            <meta http-equiv="content-type" content="text/html; charset=UTF-8" />

                <script  type="text/javascript" src="./jquery/jquery-1.9.1.js"> </script>
        </head>

    <body>   

    <div id="selectFile" >

    </div>

    <h2>Pick A Database to Restore.</h2>

    <?php

    echo "<form id='frm1' action='' method='post'>";
    echo "<select id='mySelect'  name='DBase'>"
    echo "<option value=''>Select...</option>";


        for($i=0; $i<count($pickFile); $i++) {       
          echo "<option value='".($i+1)."'>".$pickFile[$i]."</option>";
          
       }

    echo "<select>";

    echo "<input type='submit' name='submit' value='Get DataBase' >";

    echo "</form>";

    ?>



    <script type="text/javascript" >

    </script>



    <script type="text/javascript" >

    var choice="";
    var database="accounts";

    $(function() {              // BELOW - on submit do the following
        
    $("#frm1").submit(function(event ) {
        alert("Inside submit()");                        // NEVER HAPPENS
          event.preventDefault();
          choice=$("#mySelect option:selected").text();
    })        
           // ================== 1st & Only Call to Ajax() ========================

    var request = $.ajax({
        url: "restoreMySql.php",
        type: "GET",
        data: { "pwd": "pwd", "db": choice},
        dataType: "text" ,
            success: (function(retval) {
                if (retval=='ok') {
                      window.location.href='AccountsLogIn.php';   
                } else {
                   alert(" Restoring MySql "+database+" ... Was not successful.");
                   window.location.href="../index.html"
                     
                } // else    
            }) // success from 1st call    
    }) // end ajax-1

         request.fail(function(jqXHR, textStatus ) {
           alert("go see firebug");
            document.write("Request failed: " + textStatus );   
        })    
     // ===========  End 1st Call ============
     
     })       
     </script>

    </body>
    </html>