<script>
function myFunction(val) {
alert("The input value has changed. The new value is: " + val);
**var var1 = val;
$.ajax({
url: 'your_script.php',
type: 'POST',
data: {var1: javascript_var_1},
success: function(data) {
console.log("success");
}
});**
这是我放置ajax代码的地方。
var ele = document.getElementById('insertHere');
ele.innerHTML = '<input class="form-control" name="fullname" placeholder="Student Full Name"
value="<?php
$var1 = $_POST['var1'];
$query = "SELECT * FROM student WHERE studentID = '$var1' ";
$result = mysqli_query($con,$query);
$row = mysqli_fetch_array($result);
echo $row['fname'].' '.$row['mname'].' '.$row['lname'];
?>" readonly/>';
}
</script>