elis Posted April 1, 2009 Share Posted April 1, 2009 I have this snippet in PHP <?php <td> <span id="divCustomerInfo"></span> <a href="view_candidate.php?id='.$row['candidate_id'].$rhighlight.$whighlight.'" title="View Candidate Profile" target="_blank" onclick="requestCustomerInfo(' . $row['candidate_id'] . ')">'.$row['fullname'].' </a> </td> ?> Where "$row['candidate_id'] is a distinct ID. The actual page contains a list of the above, but each row[candidate_id] is different based on what was pulled from MYSQL. "onclick="requestCustomerInfo(' . $row['candidate_id'] . ')">" Uses AJAX to do a MYSQL query whose results appear here <span id="divCustomerInfo"></span> My problem is that each time the query is pulled, the results appear only in the first instance of "<span id="divCustomerInfo"></span>" and that's it. The page contains about 50 rows of different candidates and I want each row to contain matching information. Here is the javascript that requestCustomerInfo() uses <script type="text/javascript"> var url = "ptest.php?id="; // The server-side script function handleHttpResponse() { if (http.readyState == 4) { if(http.status==200) { var results=http.responseText; document.getElementById('divCustomerInfo').innerHTML = results; } } } function requestCustomerInfo(strg) { var sId = strg; http.open("GET", url + escape(sId), true); http.onreadystatechange = handleHttpResponse; http.send(null); } function getHTTPObject() { var xmlhttp; if(window.XMLHttpRequest){ xmlhttp = new XMLHttpRequest(); } else if (window.ActiveXObject){ xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); if (!xmlhttp){ xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); } } return xmlhttp; } var http = getHTTPObject(); // We create the HTTP Object </script> And ptest.php is just a page with a simple mysql select query. Does anybody know how I should can put identifiers of some sort in so that when the results from the query print, they print in the appropriate cell (based on the aforementioned $row['candidate_id']? Link to comment https://forums.phpfreaks.com/topic/152132-identfiers-in-javascriptphp/ Share on other sites More sharing options...
elis Posted April 1, 2009 Author Share Posted April 1, 2009 Better question, is what I'm looking for even possible? If not, could someone suggest an alternative? Link to comment https://forums.phpfreaks.com/topic/152132-identfiers-in-javascriptphp/#findComment-799021 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.