display.htm:
Código:
display2.hym:<!DOCTYPE html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <frameset rows="100%,0" frameborder="0"> <frame name="displayFrame" src="display2.htm" noresize="noresize"> <frame name="hiddenFrame" src="about:blank" noresize="noresize"> </frameset> <body> <div id="divCustomerInfo"></div> </body> </html>
Código:
getCustomerdata.php:<!DOCTYPE html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <script type="text/javascript"> function requestCustomerInfo(){ var sId = document.getElementById("txtCustomerId").value; top.frames["hiddenFrame"].location = "getCustomerdata.php?id=" + sId; } function displayCustomerInfo(sText){ var divCustomerInfo = document.getElementById("divCustomerInfo"); divCustomerInfo.innerHTML = sText; } </script> </head> <body> <p>Enter customer ID number:</p> <p>Customer id: <input type="text" id="txtCustomerId" value=""/></p> <p><input type="button" value="Get customer Info" onClick="requestCustomerInfo()"/></p> </body> </html>
Código:
Un saludo y gracias! <!DOCTYPE html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script type="text/javascript"> window.onload = function(){ var divInfoToReturn = document.getElementById("divInfoToReturn"); top.frames["displayFrame"].displayCustomerInfo(divInfoToReturn.innerHTML); } </script> <title>Untitled Document</title> <?php include("start.php"); $sID = $_GET["id"]; $sInfo = ""; $squery = "SELECT * FROM Customers WHERE CustomerId=".$sID; if($oResult = mysql_query($sQuery) and mysql_num_rows($oResult) > 0){ $aValues = mysql_fetch_array($oResult,MYSQL_ASSOC); $sInfo = $avalues["Name"]."<br/>".$aValues["Address"]."<br/>"; } else { $sInfo = "Customer with ID $sID no existe"; } ?> </head> <body> <div id="divInfoToReturn"><?php echo $sInfo; ?></div> </body> </html>