0

I have three separate tab panels with each being a table in my database. What i'm trying to do is that on a click of a button is save the content of all the three tabs in the database at the same time. I managed to do so by activating the tabs, then passing it certain value. However when i remove both alert functions from my code, i'm getting that B.RECORD is undefined. Any help on this?

      tabPanel.setActiveTab(1);
      tabPanel.setActiveTab(2);
      tabPanel.setActiveTab(0);

var B= window.frames["frm_B"];
var C= window.frames["frm_C"];

alert(B);
alert(C);
try {
    B.RECORD.getField("AID").setRealValue(aid);
    C.RECORD.getField("AID").setRealValue(aid);
    B.RECORD.update();
    C.RECORD.update();
    parent.refreshGrid();
    parent.win.close();
Praveen Kumar Purushothaman
  • 164,888
  • 24
  • 203
  • 252
mikeb
  • 709
  • 2
  • 9
  • 35

1 Answers1

2

This looks like the alert() gives you some time to load the iframes. You need to either use:

  1. setTimeout giving an arbitrary load time for the frames.
  2. Use .load() event of the frames.

I would prefer you use the .load() event, because it is dependable. So for that, put the following code and beyond inside the load event of the iframe:

try {
    B.RECORD.getField("AID").setRealValue(aid);
    C.RECORD.getField("AID").setRealValue(aid);
    B.RECORD.update();
    C.RECORD.update();
    parent.refreshGrid();
    parent.win.close();

The load event can be done using: Javascript callback when IFRAME is finished loading?

Community
  • 1
  • 1
Praveen Kumar Purushothaman
  • 164,888
  • 24
  • 203
  • 252