How to reload Frames with new data?

Dear friends,

I have a frame. Inside the frame i am displaying a Table with datas. "onclick" of the Table header i am calling a JavaScript (onclick="JavaScipt:sort(param)) which sorts the table and writes back to the frame again.

When i write, the new table gets created below the old table and both the tables are there. I want to erase the old table from the frame and i want to write the new table in the frame. Is it possible.

Its done in Jsp, so if i reload the page it makes a server trip, which should not happen for sorting.

Can anybody help.

Best Regards,
Prasanna.
Prasanna23Asked:
Who is Participating?
 
COBOLdinosaurConnect With a Mentor Commented:
Put the table inside of a named:

<div id="thediv" style="position:absolute">
table stuff
<div>

The do the rewrite this way:

if (document.all)
{
   parent.f3.document["thediv"].innerHTML=output;
}
else
{
   if (document.layers)
   {
      parent.f3.document.layers["thediv"].document.write(output);
      parent.f3.document.layers["thediv"].document.close();
   }
}

That should overwrite the original table inside the div instead of appending the way it is doing now.

Cd&
0
 
COBOLdinosaurCommented:
Can you post that part of the code that rewrites the table, and the HTML for
the frame with the table?

Cd&
0
 
bebonhamCommented:
the only way to do it is to write all you variables into another frame in the frameset. (in javascript)

that frame can write and rewrite as much as it likes

but it will all have to be handled in javascript

do you need more information or a sample?

Bob
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

 
pstavrinidesCommented:
create multiple div tags over one another, and set the position to absolute... use the visability property to hide/show your specific table when you want to.
0
 
bebonhamCommented:
yeah, but you cannot make a div tag and table of every possibility.

that would not be a dynamic solution.

if all the data is written into a javascript array, then the controling frame can change the table to any possibility without the use of divs.

Bob
0
 
Prasanna23Author Commented:
Dear Bob,

I am already using javascript array to store all my table data. I have already tried with div tag, it keeps generating the code every time i show and hide. So is there any other way rewrite the frame.

Can u please give me the sample code or more information regarding how to do it.

Thanks and Best Regards,
Prasanna
0
 
Prasanna23Author Commented:
Hai,

Here with i have given the code which i used. can anybody help.

Best Regards,
Prasanna
***********************************************************
function sort(param)
{
     alert("sort");
     myObjectBubbleSort(myObjectArray,objectArrayIndex,param);
     output="";
     showObjectArray(myObjectArray,objectArrayIndex);
}

function myObjectBubbleSort(arrayName,length,property) {
                         
     for (var i=0; i<(length-1); i++)
         for (var j=i+1; j<length; j++)
             if (eval('arrayName[j].' + property + '<arrayName[i].' + property))
          {
                 var dummy = arrayName[i];
                 arrayName[i] = arrayName[j];
                 arrayName[j] = dummy;
                 }
     alert('bubble');
}


function showObjectArray(object, length)
{    
    var l1= 0;
                         
    output += '<table bgcolor="FFDDB0" border="2"><tr><th><span onclick="JavaScript:sort(\'name1\')" style="color:blue; cursor:hand;">name1</span></th><th><span onclick="JavaScript:sort(\'name2\')" style="color:blue; cursor:hand;">name2</span></th><th><span onclick="JavaScript:sort(\'name3\')" style="color:blue; cursor:hand;">name3</span></th><th><span onclick="JavaScript:sort(\'name4\')" style="color:blue; cursor:hand;">name4</span></th><th><span onclick="JavaScript:sort(\'name5\')" style="color:blue; cursor:hand;">name5</span></th><th><span onclick="JavaScript:sort(\'name6\')" style="color:blue; cursor:hand;">name6</span></th><th><span onclick="JavaScript:sort(\'name7\')" style="color:blue; cursor:hand;">name7</span></th><th><span onclick="JavaScript:sort(\'name8\')" style="color:blue; cursor:hand;">name8</span></th><th><span onclick="JavaScript:sort(\'name9\')" style="color:blue; cursor:hand;">name9</span></th><th><span onclick="JavaScript:sort(\'name10\')" style="color:blue; cursor:hand;">name10</span></th><th><span onclick="JavaScript:sort(\'name11\')" style="color:blue; cursor:hand;">name11</span></th></tr>';

    for (l1=0; l1<length; l1++)
    {
     output += '<tr>';
     output += '<td>';
     output += object[l1].name1;
     output += '</td>';
     output += '<td>';
     output += object[l1].name2;
     output += '</td>';
     output += '<td>';
     output += object[l1].name3;
     output += '</td>';
     output += '<td>';
     output += object[l1].name4;
     output += '</td>';
     output += '<td>';
     output += object[l1].name5;
     output += '</td>';
     output += '<td>';
     output += object[l1].name6;
     output += '</td>';
     output += '<td>';
     output += object[l1].name7;
     output += '</td>';
     output += '<td>';
     output += object[l1].name8;
     output += '</td>';
     output += '<td>';
     output += object[l1].name9;
     output += '</td>';
     output += '<td>';
     output += object[l1].name10;
     output += '</td>';                                  
     output += '<td>';
     output += object[l1].name11;
     output += '</td>';                                  
     output += '</tr>';
    }

    output += '</table><div style="background-color:green; position:absolute; width:100px; height:100px; top:25px; left:25px; visibility:hidden;" id="menu"><a onclick="operation(0)"><u>Stop</u></a><br/><a onclick="operation(1)"><u>Start</u></a><br/><a onclick="operation(2)"><u>Pause</u></a><br/><a onclick="operation(3)"><u>Continue</u></a></div>';
    alert(output);
    parent.f3.document.write(output);
     
}




0
 
COBOLdinosaurCommented:
Looking at your code it looks like it is IE specific in whch case you don't need the whole thing; just:

  parent.f3.document["thediv"].innerHTML=output;

should do it.

Cd&
0
 
Prasanna23Author Commented:
HI Cd&,

You r simply Great. Million thanks to u. It worked. I owe u a drink.

Thanks a lot again,
Best Regards,
Prasanna
0
 
Prasanna23Author Commented:
Thanks
Best Regards,
Prasanna

0
 
COBOLdinosaurCommented:
Glad I could help.  Thanks for the A. :^)

Cd&
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.