Dynamic Form creation not working

Dynamic Form creation not working

Hi,

I've been trying to create a form by appending to <div id='what'> with no success.

The form displays fine including data values but the submit  does not display the alert() message. My goal is to view the data returned, change the data if desired, and send the changed data thru AJAX to update my MySql database.
  1. function showReturn(data) {    //  <========= data is returned from AJAX.
       
    $("#results").hide();  // hide previous
    $("#what").show();   // show current

    $("#what").append("<form method='post' id='myForm' action=''> ");
     
    $("#what").append("<label for='DL'>DL:</label>");                             
    $("#what").append("<input type='text' name='DL' id='DL' value="+data.DL+"><br>");

    $("#what").append("<label for='DL_Expiry'>DL_Expiry:</label>");
    $("#what").append("<input type='text' name='DL_Expiry' id='DL_Expiry' value="+data.DL_Expiry+"><br>");

    $("#what").append("<label for='PassPort_No'>PassPort_No:</label>");
    $("#what").append("<input type='text' name='PassPort_No' id='PassPort_No' value="+data.PassPort_No+"><br>");

    $("#what").append("<label for='PP_Expiry'>PP_Expiry:</label>");
    $("#what").append("<input type='text' name='PP_Expiry' id='PP_Expiry' value="+data.PP_Expiry+"><br>");

    $("#what").append("<label for='subm'>Save:</label>");
    $("#what").append("<input type='submit' name='subm' >");

    $("#what").append("</form>");


    $("form#myForm").submit(function(){
        alert("Submitted");                          //   <=========== does not display
    });

    } // showReturn