topical media & game development

talk show tell print

professional-ajax-02-Hidden-IFrame-Examples-HiddenIFrameExample2.htm / htm



  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  
  <html>
  <head>
      <title>Customer Account Information</title>
      <script type="text/javascript">
          var oIFrame = null;
          
          function createIFrame() {
              var oIFrameElement = document.createElement("iframe");
              oIFrameElement.width=0;
              oIFrameElement.height=0;
              oIFrameElement.frameBorder=0;
              oIFrameElement.name = "hiddenFrame";
              oIFrameElement.id = "hiddenFrame";
              document.body.appendChild(oIFrameElement);
              
              oIFrame = frames["hiddenFrame"];
          }
          
          function requestCustomerInfo() {
              if (!oIFrame) {
                  createIFrame();
                  setTimeout(requestCustomerInfo, 10);
                  return;
              }
              
              var sId = document.getElementById("txtCustomerId").value;
              oIFrame.location = "GetCustomerData.php?id=" + sId;
          }
          
          function displayCustomerInfo(sText) {
              var divCustomerInfo = document.getElementById("divCustomerInfo");
              divCustomerInfo.innerHTML = sText;
          }
      </script>
  </head>
  <body>
      <p>Enter customer ID number to retrieve information:</p>
      <p>Customer ID: <input type="text" id="txtCustomerId" value="" /></p>
      <p><input type="button" value="Get Customer Info" onclick="requestCustomerInfo()" /></p>
      <div id="divCustomerInfo"></div>
  </body>
  </html>
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.