Jump to content

!!HELP!! Trouble with Ajax <INPUT> function!


POGRAN

Recommended Posts

Hi there, guys!
I have a search page on my web site that gets the information about user by his username from MySQL database.
It has two input fields: username and full name
A visitor is typing in the username field his username, clicks on "Get Name" link and in the second field he sees his name.

I know that it is possible to realize it in Ajax. I wrote already some code, you can see it's source here:
[url=http://www.pogran.nm.ru/xajax.txt]http://www.pogran.nm.ru/xajax.txt[/url]
(it uses xAjax class)

The only problem is that it doesn't get the full name correctly, it gets the fullname of user whose username = "". That means that the function check() doesn't see the $username (field's data)

What is wrong with the script can you help me please guys!?
Thanks in advance!
Link to comment
Share on other sites

function check([color=red]$asd[/color])  ?

Try:
[code]
function check($username)  {
                $result = "SELECT * FROM users WHERE username='$username'";
                $result_sql = mysql_query ($result);
                $myrow = mysql_fetch_array($result_sql);
                $name = $myrow["name"];

  $objResponse = new xajaxResponse();
  $objResponse->addAssign('full_name', 'value', $name);
  return $objResponse->getXML();;
  }
[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.