将页面内容放在输入值中不起作用

时间:2022-08-23 12:42:12

This is what I'm trying to maintain:

这就是我想要维护的内容:

I have two inputs, #e_adres and #e_nummer. When I click on #e_nummer, I want to do this query: mysql_query("SELECT b_nummer FROM km WHERE b_adres = '".$_GET['adres']."' ORDER BY nr DESC LIMIT 1") or die(mysql_error());

我有两个输入,#e_adres和#e_nummer。当我点击#e_nummer时,我想做这个查询:mysql_query(“SELECT b_nummer FROM km WHERE b_adres ='”。$ _ GET ['adres']。''ORDER BY nr DESC LIMIT 1“)或者死(mysql_error( ));

And I want the result of that query to become the value of my second input, #e_nummer.

我希望该查询的结果成为我的第二个输入#e_nummer的值。

So I've put this script in my page:

所以我把这个脚本放在我的页面中:

$( "#e_nummer" ).click(function() {
    var a = $('#e_adres').val();
    var g = $.get( "e_nummer.php", { adres: a } );
    $( "#e_nummer" ).val( g );
});

In e_nummer.php is the following:

在e_nummer.php中如下:

header('Content-Type: text/plain; charset=utf-8');
mysql_connect("localhost", "user", "pass") or die(mysql_error());
mysql_select_db("km") or die(mysql_error());
$result = mysql_query("SELECT `b_nummer` FROM `km` WHERE `b_adres` = '".$_GET['adres']."' ORDER BY `nr` DESC LIMIT 1") or die(mysql_error());
$row = mysql_fetch_array( $result );
echo $row['b_nummer'];

But the value of the input becomes [object Object] instead of $row['b_nummer']. Does anyone know how to get this working?

但是输入的值变为[object Object]而不是$ row ['b_nummer']。有谁知道如何使这个工作?

1 个解决方案

#1


0  

try something like this

尝试这样的事情

$( "#e_nummer" ).click(function() {
    var a = $('#e_adres').val();
   $.get( "e_nummer.php", { adres: a },function(data){
        $( "#e_nummer" ).val( data );
    });
})

#1


0  

try something like this

尝试这样的事情

$( "#e_nummer" ).click(function() {
    var a = $('#e_adres').val();
   $.get( "e_nummer.php", { adres: a },function(data){
        $( "#e_nummer" ).val( data );
    });
})