我有两个脚本......
1。 HTML部分:
<html>
<head>
<script src="//code.jquery.com/jquery-1.9.1.js"></script>
<script>
function loaddata()
{
var email=document.getElementById( "email" );
var email1 = $(email).val();
if(email1)
{
$.ajax({
type: 'post',
url: 'form-inputs.php',
data: {
user_email:email1,
},
success: function (response) {
// We get the element having id of display_info and put the response inside it
$( '#display_info' ).html(response);
}
});
}
else
{
$( '#display_info' ).value("Please Enter Some Words");
}
}
</script>
</head>
<body>
<input name="email" id="email" onkeyup="loaddata();" required/>
<br><br>
<input name="udf1" id="udf1" readonly="readonly"/>
<br>
<div id="display_info" ></div>
</body>
</html>
2。 form-inputs.php:
<?php
$con = mysql_connect("localhost","username","password");
if (!$con)
{
die("Could not connect: " . mysql_error());
}
mysql_select_db("databasename", $con);
##############################
if( isset( $_POST['user_email'] ) ){
$emailfetch=$_POST['user_email'];
$sqlraw = "select username, email from registration where email = '$emailfetch' ";
$sql=mysql_query($sqlraw);
while($row=mysql_fetch_array($sql)){
if(isset($row['email'])){
echo $row['username']; //shown only if post email exists in database
}else{
echo "Check Email Again";
}
}
}
?>
使用这些代码,我会在ID为display_info
的div中正确显示用户名。
但我想在我的第二个 udf1
输入字段中使用并设置此用户名值。
帮助表示赞赏。
答案 0 :(得分:2)
使用此
newTabSpec()
这个
的实例#include <iostream>
#include <vector>
int main(void) {
// works
void (vector<int>::*pb)(const vector<int>::value_type&)
= &vector<int>::push_back;
// not work
auto pbb = std::mem_fn(&vector<int>::push_back);
return 0;
}
答案 1 :(得分:1)
你试过这个吗?
$('#udf1').val(response);
后
$( '#display_info' ).html(response);
可能会有所帮助。