View Full Version : Ajax write response in different span tags with an ID generated with PHP

01-19-2009, 06:30 PM
First of all, HI. it's my first post.
I don't even know if this is the way to approach the problem, if not, please tell me. Here is what I am doing and what I want to do:

JS to output server response:
if(xmlHttp.readyState ==4)
document.getElementById("response").innerHTML =xmlHttp.responseText;

<span id="response">Here comes the response:</span>

I got this to work. However, I want the feedback to be in different spans depending on the unique id that I generate with PHP.

<span id="response<?php echo $uniqueid; ?>">Here comes the response:</span>

if the entry with id 5 is updated, i want the response to go to the span with response5 and no others.

I don't know how to approach this problem.

01-20-2009, 04:44 PM
however you're calling your ajax.... pass the id as an arg

<span id="<?php echo $uniqueid; ?>" onclick="domyajax('<?php echo $uniqueid; ?>');">Here comes the response:</span>