我的html表单在提交之前生成信息。
<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();
});
}
使用//generate.php
获取 $fname = $_POST['fname'];
echo display_records($fname,$mname,$lname);
//add javascript here ex (disabled submit button if its empty OR add prevent double submit//
<form>
//form goes here
</form>
如果空http://jsfiddle.net/He4Kv/7/
,则停用该表单流量:
generate fullname(submit.js) > display result with form(generate.php) > then submit
问题是当在generate.php中添加javascript时它不起作用。(在generate.php中添加禁用的脚本不起作用)