View Full Version : Ajax display responseText in multiple fields

06-26-2009, 01:47 AM
1) Script Title:

2) Script URL (on DD): http://www.dynamicdrive.com/forums/forumdisplay.php?f=2

3) Describe problem:
Hi I am very new to Ajax and programming in general, I need to display the results from Ajax into several different text fields. I can currently display all fields into a Div, but can not split and display as separate elements. I need to display the PHP results in the corresponding HTML fields.

//Ajax code
ajaxRequest.onreadystatechange = function(){
if(ajaxRequest.readyState == 4){
var ajaxDisplay = document.getElementById('ajaxDiv');
ajaxDisplay.innerHTML = ajaxRequest.responseText;

//PHP result
while($row = mysql_fetch_array($qry_result)){
$display_name .= "$row[currency_name]";
$display_symbol .= "$row[currency_symbol]";
$display_code .= "$row[currency_code]";

echo $display_name;
echo $display_code;
echo $display_symbol;

//HTML fields for results to be displayed.
Name:<input type="text" id='display_name'/>
Code:<input type="text" id='display_code'/>
Symbol:<input type="text" id='display_symbol'/>