Hi
This post was starting to grow out of controll and I solved one of my problems. So insted of presenting a long boring post to get help I just rewrote it to be more precise. I had two questions/problems that I wanted some help with. The second problem I solved by my self after some hours of reading and googling. I'll present the solution here.
But first my unsolved problem.
I've got the famous traditional form that you see on every pages for input of data.
My mission is to let the user type in a customer ID (namebased) and by using ajax I retrieve the customers data from the mysql table and put those values into the rest of the form input boxes.
But, I want this to have an inbuilt search function aswell.
This is okay. I have written my ajax onkeyup function that send the ID to another php file that does all the mysql stuff. (and search function) And when the user types "a" it lists the 10 first positive hits in the mysql table for customer ID's starting with the letter "a" in a little <div> window below the input box. So far so good.
So, I'm able to request and get back my data, but not use it like I would. Let me explain. When the user types "a" and the list get populated, I would like for the user to be able to use his/hers arrow keys on his/hers keyboard to select the right entry, confirming by using the enter key. And by selecting, put the selected ID in the same input box and also get the rest of the mysql table data for that ID entry into the rest of my inpux box'es. I guess I can return an array holding my data, but how do I put item for item in seperate input box'es?
I guess that's two questions in the same problem, but a push in the right direction would help me alot here.
A new quick question.
When I've got the right customer ID and populated the rest of the form input box'es, I would like to be able to edit those inputboxes and let the user press a button for "update customer data". Is this possible? Or do I have to re-read the forms input box'es ID fields into a new array of php variables and run then run a mysql update?
Then to the SOLVED issue I had.
My second problem/question was about getting php variables bach with ajax (not sure how to describe this problem precise) It's on the same scenario. This is how I solved it.
index.php
session_start();
form with onkeyup do ajax thing and get result from find.php
find.php
session_start();
do mysql query
$region = $row["fylke"];
session_register("region");
$_SESSION["region"] = $fylke;
set xml headers and send back the dynamic ajax content to index.php (do not send session here, it's already set)
back to index.php and after the ajax output, I put :
$region = $_SESSION["region"];
After I type in a valid customer ID and got 1 positive respons and reload the main index.php file it prints out the region. So I guess I'm good to go with this one.
Thank you for your time and for any feedback on this.