Date:  04/23/2014 11:31:59 AM Msg ID:  004684
From:  FoxWeb Support Thread:  004682
Subject:  Re: Master Table / Child Table
Conceptually this solution is fine, but I recommend that you use a javascript library like jQuery to implement ajax, so as to avoid having to account for differences between the various browsers and browser versions.
FoxWeb Support Team
support@foxweb.com email
Sent by Ali Koumaiha on 04/23/2014 10:31:35 AM:
I figured it out.
In may fwx page 
InvoiceListing.fwx (my page)

<head>

<script>
function loadXMLDoc(tnIID)
{
var xmlhttp;
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("invDetail").innerHTML=xmlhttp.responseText;
    }
  }

xmlhttp.open("POST", "getInvoiceDetail.fwx?tnIID="+ escape(tnIID), true);
xmlhttp.send();
}
</script>

</head>

<body>

..

...

...

<div id="invDetail></div>

 
 
then, I have another script, that takes a paramter and does this:
 
GetInvoiceDetail.fwx
<%
Private lnIID
lnIID    = request.querystring("tnIID")
if empty(lnIID)
    return
endif

text to lcSQL noshow
    Execute GetInvoiceDetailByIID ?lnIID       
endtext    
gosql.execute(lcSQL,'curInvDetail')
if SQLError()
    response.write('Error retrieving invoice detail')
    return
endif

%>

<table width="100%" border="1">
  <tr>
     <td>Item Number</td>
     <td>Item Description</td>
     <td>Qty</td>
     <td>Price</td>
     <td>Tax?</td>
     <td>Tax Amnt</td>
     <td>Discount</td>
     <td>Sub-Total</td>
     <td>Serial Number</td>
     <td>Mobile No.</td>    
  </tr>
  <%
  select curInvDetail
  scan
  %>
     <tr>
       <td><%=Item%></td>
       <td><%=Itmdesc%></td>
       <td><%=Qty%></td>
       <td><%=Price%></td>
       <td><%=iif(Taxable,'Yes','No')%></td>
       <td><%=TaxAmount%></td>
       <td><%=Discount%></td>
       <td><%=SubTotal%></td>
       <td><%=Serial%></td>
       <td><%=PTN%></td>
     </tr>
  <%endscan%>
</table>
 
 
Sent by Ali Koumaiha on 04/23/2014 09:13:37 AM:
 I am trying to figure out the best way to do this.
I have an fwx page, has an html table (grid) with rows from a master table.
first column is invoice#.
 
at the bottom, i have another html table, that should display the detail of the invoice.
 
i can put the data on both, and use a querystring and get the invoice# of selected record and display.  All is good.
 
 
But, the page is "refershing" and the user doesn't see the selected row any more.
 
so, what i want to accomplish, is to try to load the child table using maybe javascript or ajax without doing a post on the client side or refreshing the browser using normal post.
 
can you simply point me in the right direction? how i can do a postback using ajax from a onlick of a record or a row inside an html table?