Hey Scott,
Glad to be of help. Some of the more involved jQuery functions take a while getting used to, and I've still certainly got a lot to learn... Once you get the basic mechanics of your form working, you may want to add a visual cue to your users that fields have been updated. I used the nifty highlightFade plugin: http://jquery.offput.ca/highlightFade/ to highlight autocompleted fields in a zipcode lookup I created (the basis for the code I gave you) Or even an annoying audio cue, using my jMP3 plugin (shameless plugin plug!): http://www.sean-o.com/jquery/jmp3/ ...perhaps a soft, brief harp sound -- player hidden, and set to autoplay on completion. ;) ________ SEAN O Scott Sharkey wrote: > > Sean, > > That is an awesome answer - THANKS. I've been having trouble getting my > head around the way that AJAX works in jQuery, and this is the first one > that I've seen that "connected the dots" for me. THANK YOU. > > -Scott > > Sean O wrote: >> Hi Scott, >> >> >> Here's a suggestion: >> >> // autofill customer information from email >> $("#email").blur(function(){ >> var emailaddr = $("#email").val(); >> // AJAX send to email lookup, which outputs XML data >> $.post("checkemail.php",{ email: emailaddr }, >> function(xml){ >> // fill location fields with data >> returned >> from email lookup >> var state = $("state",xml).text(); >> var city = $("city",xml).text(); >> // etc. etc. >> >> // now update fields >> $("#state").attr("value",state); >> $("#city").attr("value",city); >> // etc. etc. >> }); >> } >> >> checkemail.php does a db lookup & returns XML: >> (example uses PHP/MySQL - you could easily use other lookups like >> ASP/MSSQL, >> etc.) >> >> <?php >> header('Content-type: text/xml'); // output as XML >> $email=$_REQUEST['email']; >> >> // define dB connection vars... >> >> // connect to MySQL & load database >> mysql_connect('localhost',$username,$password); >> if ([EMAIL PROTECTED]($database)) { exit('<p>Unable to locate the ' . >> $database . ' database at this time.</p>'); } >> >> // retrieve customer data >> $query="SELECT * FROM customers WHERE (Email=$email)"; >> $result=mysql_query($query); >> if (!$result) { exit('<p>Error performing query: ' . mysql_error() . >> '</p>'); } >> >> // close db >> mysql_close(); >> >> while ($row = mysql_fetch_array($result)) { >> $city = $row['City']; >> $state = $row['State']; >> // etc. etc. >> } >> >> $returnXML = >> "<response><city>$city</city><state>$state</state>...</response>"; >> echo $returnXML; >> ?> >> >> >> >> Scott Sharkey wrote: >>> Hi All, >>> >>> Brand new to jQuery, and looking for suggestions. I have a "customer" >>> form, that I need to do a lookup when they enter their email address, >>> and have it fill in the name, address, city, state, zip, etc if they are >>> already in the database. >>> >>> I am not following the ajax tutorials that I've found online so far very >>> well. Can anyone suggest some good, simple tutorial, or is there an >>> example piece of code somewhere that fills in multiple fields when one >>> changes? >>> >>> Thanks a bunch! >>> >>> -Scott >>> >>> _______________________________________________ >>> jQuery mailing list >>> [email protected] >>> http://jquery.com/discuss/ >>> >>> >> > > > _______________________________________________ > jQuery mailing list > [email protected] > http://jquery.com/discuss/ > > -- View this message in context: http://www.nabble.com/Ajax-to-update-multiple-fields-tf2437343.html#a6803368 Sent from the JQuery mailing list archive at Nabble.com. _______________________________________________ jQuery mailing list [email protected] http://jquery.com/discuss/
