Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to refer object in 2 level frames

Status
Not open for further replies.

jimmyweb

Programmer
Dec 9, 2004
37
US
Hi Friends,

I have 2 level frame fo a project.
each level object works well if we run iteach separetely. The javascript code at second level frame pay_report.html works well under independent testing.
But if I integrated in into first level and test it. the second frame javascript code does not working. I thought that refres first level
frame as frames[0] and second frame as frames[2].
I modify second frame file javaScript code and added frames[0].frames[1]. for refers at document sytax begin. But it does not work.
i got some error message error:"frames.0.frames' is null or not an object.
which problem? How to fix it?
Thanks for any help.
See attach 2 level frame codes

Jim
****************first level frame

<html>
<frameset frameborder="1" framespacing="2" border="1" cols="*" rows="60,*">
<frame marginwidth="0" marginheight="0" src="rpt_head.html" name="heading" noresize scrolling="no">
<frameset frameborder="1" framespacing="1" border="0" cols="275,*" rows="*" BORDERCOLOR="#CC0000">
<frameset frameborder="0" framespacing="0" border="0" cols="*" rows="0,*">
<frame marginwidth="0" marginheight="0" src="rpt_code.html" name="code" noresize scrolling="no" frameborder="0">
<frame marginwidth="5" marginheight="5" src="rpt_menu_empty.html" name="menu" noresize scrolling="auto" frameborder="0">
</frameset>
<frame marginwidth="5" marginheight="5" src="rpt_main.html" name="text" noresize>
</frameset>
</html>

****************second level frame in rpt_menu_empty.html
<html>
<frameset rows"28, *%">
<frame name="optFrame" src="pay_report.html">
<frame name="hiddenForm" src="form_hidde.html">

</frameset>
<html>

**************** javascript code at second level frame pay_report.html files


<html>
<head>
<style>
.Invisible
{
visibility: hidden;
}
.Visible
{
visibility: visible;
}
</style>
</head>
<script language="JavaScript">

var txtValue;
var arrDDT1 = new Array("Total","Client","Product","Dept","Group","Collector","GSEN","Monarch","Colonial","Platinum","Platinum2","Platinum3","Sage","Rec.Svcs");
var arrDDT2Values = new Array("All;Client;Product;Dept;Group;Collector","All;Product;Dept;Group;Collector","All;Dept;Group;Collector","All;Client;Product;Group;Collector","All;Client;Product;Collector","All;Client;Product","All;Product;Dept;Group;Collector","All;Product;Dept;Group;Collector","All;Product;Dept;Group;Collector","All;Product;Dept;Group;Collector","All;Product;Dept;Group;Collector","All;Product;Dept;Group;Collector","All;Product;Dept;Group;Collector","All;Product;Dept;Group;Collector");
//Right now no use of this, but in future may be implemented
var NO_OF_COLUMNS=2;
//DDT2 Array Size
var lenDDT2= arrDDT2Values.length;
var arrDDT2 = new Array(lenDDT2);

for(j=0;j<lenDDT2;j++)
{
arrDDT2[j] = new Array(NO_OF_COLUMNS);
arrDDT2[j][0] = arrDDT1[j];
arrDDT2[j][1] = arrDDT2Values[j];
}

function loadDDT2()
{
var selDDT1;
selDDT1 = frames[0].frames[1].document.optSel.p_ddtype1.options[frames[0].frames[1].document.optSel.p_ddtype1.selectedIndex].value;
var i=0;
var elementIndex;
for(i in arrDDT2)
{
if(arrDDT2[0] == selDDT1) {
elementIndex= i;
break;
}
}
var strDDT2Values;
var tmparrDDT2Values = new Array();
strDDT2Values = arrDDT2[elementIndex][1];
tmparrDDT2Values = strDDT2Values.split(";");
frames[0].frames[1].document.optSel.p_ddtype2.options.length=0;
for(i=0;i<tmparrDDT2Values.length;i++)
{
addToDDT2List(frames[0].frames[1].document.optSel.p_ddtype2,tmparrDDT2Values, tmparrDDT2Values);
}
//select First Element in the list
frames[0].frames[1].document.optSel.p_ddtype2.selectedIndex=0;
//changeVisibility("T1");

}

function addToDDT2List(listField, newText, newValue) {
if ( ( newValue == "" ) || ( newText == "" ) ) {
alert("You cannot add blank values!");
} else {
var len = listField.length++;
listField.options[len].value = newValue;
if (newText == "All") {
listField.options[len].text = newText;
} else {
listField.options[len].text = newText;
}
listField.selectedIndex = len;
}
}

function changeVisibility() {


txtValue = frames[0].frames[1].document.optSel.p_ddtype1[frames[0].frames[1].document.optSel.p_ddtype1.selectedIndex].value;
alert(txtValue);
if ( (txtValue == "Client") || (txtValue == "Product") || (txtValue == "Dept") || (txtValue == "Group") || (txtValue == "Collector") ){
frames[0].frames[1].document.optSel.p_txtValue1.value = "";
frames[0].frames[1].document.getElementById("p_txtValue1").className="Visible";
} else {
frames[0].frames[1].document.getElementById("p_txtValue1").className="Invisible";
}

}


function checkEntry() {
if ( (((txtValue == "Client") || (txtValue == "Product") || (txtValue == "Dept") || (txtValue == "Group") || (txtValue == "Collector")) && (frames[0].frames[1].document.optSel.p_txtValue1.value == "")) ||
(frames[0].frames[1].document.optSel.p_stdate.value == "") || (frames[0].frames[1].document.optSel.p_enddate.value == "") ) {
alert("Please make sure all fields have value entered!");
if ( (txtValue == "Client") || (txtValue == "Product") || (txtValue == "Dept") || (txtValue == "Group") || (txtValue == "Collector") ) {
frames[0].frames[1].document.optSel.p_txtValue1.focus();
} else {
frames[0].frames[1].document.optSel.p_stdate.focus();
}
}
else {
submitForm();
}
}

function submitForm() {

var radIndex;

top.frames[0].frames[1].document.optHide.p_ddtype1.value = frames[0].frames[1].document.optSel.p_ddtype1[frames[0].frames[1].document.optSel.p_ddtype1.selectedIndex].value;
top.frames[0].frames[1].document.optHide.p_ddtype2.value = frames[0].frames[1].document.optSel.p_ddtype2[frames[0].frames[1].document.optSel.p_ddtype2.selectedIndex].value;
if (txtValue.toUpperCase() != "TOTAL") {
top.frames[0].frames[1].document.optHide.p_txtValue1.value = frames[0].frames[1].document.optSel.p_txtValue1.value;
}
else {
top.frames[0].frames[1].document.optHide.p_txtValue1.value = "";
}
top.frames[0].frames[1].document.optHide.p_stdate.value = frames[0].frames[1].document.optSel.p_stdate.value;
top.frames[0].frames[1].document.optHide.p_enddate.value = frames[0].frames[1].document.optSel.p_enddate.value;

for (radIndex = 0; radIndex < frames[1].frames[2].document.optSel.p_detorsum.length; radIndex++) {
if (frames[0].frames[1].document.optSel.p_detorsum[radIndex].checked == true) {
top.frames[0].frames[1].document.optHide.p_detorsum.value = frames[0].frames[1].document.optSel.p_detorsum[radIndex].value;
break;
}
}
top.frames[0].frames[1].document.optHide.submit();
}

</script>


<body bgcolor="#CCCCCC">
<center>
<form name="optSel">

<table width="49%">
<tr>
<td colspan="7" nowrap><table width="100%" bgcolor="#999999">
<tr>
<td width="50%"><div align="center"><strong>Report</strong></div></td>
<td width="25%" ><div align="center"><strong>Date</strong></div></td>
<td width="15%"><div align="left"><strong>Type</strong></div></td>
</tr>
</table></td>
</tr>
<tr>
<td width="69" nowrap> <div align="right">Filter By:</div></td>
<td width="44"><select name="p_ddtype1" onChange="loadDDT2();changeVisibility()">
<SCRIPT>
for (i=0; i<arrDDT1.length; i++)
{
if ((arrDDT1 == "Total") || (arrDDT1 == "Collector") || (arrDDT1 == "GSEN") || (arrDDT1 == "Monarch") || (arrDDT1 == "Colonial") || (arrDDT1 == "Platinum") || (arrDDT1 == "Platinum2") || (arrDDT1 == "Platinum3") || (arrDDT1 == "Sage") || (arrDDT1 == "Rec.Svcs")){
frames[0].frames[1].document.write("<option value=" + arrDDT1 + ">" + arrDDT1 + "</option>");
}
else {
frames[0].frames[1].document.write("<option value=" + arrDDT1 + ">" + arrDDT1 + " No. </option>");
}
}
frames[0].frames[1].document.optSel.p_ddtype1.selectedIndex = 0;
</SCRIPT>
</select></td>
<td width="39"><input type="text" name="p_txtValue1" id="p_txtValue1" size="6" maxlength="6"></td>
<td width="35"><div align="right">Start:</div></td>
<td width="63"> <input type="text" name="p_stdate" size="10" maxlength="10" onBlur="validate_date(this,''Test Date'')"></td>
<td width="20"><input type="radio" name="p_detorsum" value="detail" ></td>
<td width="87"> Detail</td>
</tr>
<tr>
<td width="69" nowrap> <div align="right">Group By:</div></td>
<td> <select name="p_ddtype2" >
<SCRIPT>
loadDDT2();
</SCRIPT>
</select></td>
<td>&nbsp;</td>
<td><div align="right">End:</div></td>
<td><input type="text" name="p_enddate" size="10" maxlength="10" onBlur="validate_date(this,''Test Date'')"></td>
<td><input type="radio" name="p_detorsum" value="summary" checked> </td>
<td> Summary</td>
</tr>
<tr>
<td colspan="7">
<font size="1" color="darkred" face="Arial, Helvetica, sans-serif">* All fields are required. If you need report for 1 day, enter same value for START and END fields.</font></td>
</tr>
<tr>
<td colspan="7"><div align="center">
<input name="p_submit" type="button" value="Get Report" onClick="checkEntry()">
&nbsp;
&nbsp;
<input type="reset" value="Clear">
</div></td>
</tr>
</table>
</form>
<SCRIPT>
changeVisibility();
</SCRIPT>
</center>
</body>
</htm>
***********************working as independ html file
 
wow...did you leave anything out?

why don't you cycle through all the elements on the screen? for instance, if you have a form you can call all the elements of that form...try that for frames.

obviously if you call all the frames from a window, your frame that's 'missing' won't show up, but you can start there...

maybe it's there, but you have layered it, or you need to reference in a special way...i'm not to familiar with frames, but i'm sure they're not too complicated...if you could submit code that is just an example of what you want it to display...(all the necessary frame html, but not the content, etc).

i find that most stuff is the way i find it on the screen, ie the DOM...

- g
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top