javascript - jquery doesnt work when using this approach -
my html form generate info before submiting it.
<script type="text/javascript" language="javascript" src="js/jquery.min.js"></script> <script type="text/javascript" language="javascript" src="js/submit.js"></script> <form id="myform" class="form-horizontal" method="post"> <input type="text" id="lname" name="lname"required> <input type="text" id="fname" name="fname"required> <input type="text" id="mname" name="mname"required> <input type="button" id="submitformdata" onclick="submitformdata();" value="generate" /> </form> <div id="results1"> <hr> </div>
//submit.js
function submitformdata() { var lname = $("#lname").val(); var fname = $("#fname").val(); var mname = $("#mname").val(); $.post("generate.php", { lname: lname, fname: fname, mname: mname}, function(data) { $('#results1').html(data); $('#myform')[0].reset(); }); }
get using //generate.php
$fname = $_post['fname']; echo display_records($fname,$mname,$lname); //add javascript here ex (disabled submit button if empty or add prevent double submit// <form> //form goes here </form>
disabled form if empty http://jsfiddle.net/he4kv/7/
flow:
generate fullname(submit.js) > display result form(generate.php) > submit
the problem when adding javascript inside generate.php doesnt work.(adding disabled script doesnt work inside generate.php)
Comments
Post a Comment