Forum Moderators: open

Message Too Old, No Replies

javascript error 'has no properties' in Firefox

         

ajonas

4:49 pm on May 4, 2006 (gmt 0)

10+ Year Member



I have a frameset where the page in the "upper_frame" passes data to a field on a form in the "lower_frame". This works fine in IE, but produces a "parent.lower_frame.frmCount has not properties" javascript error. During troubleshooting, I threw in some alerts() and it seems the problem lies with the browser identifying the form:
alert(parent.lower_frame); -> Shows "[object Window]"
alert(parent.lower_frame.frmCount); -> Shows "undefined"

Here's the frameset
------------------------------------------------
<frameset rows="200,*" cols="*" framespacing=0 frameborder=no border=1>
<frame src="getcount.php?lots=1" name="upper_frame" id="upper_frame"
marginheight=0
marginwidth=0
noresize>
<frame src="lot/avail_options.php?avail=1&revise_search="
name="lower_frame" id="lower_frame"
marginheight=5
marginwidth=5
scrolling=auto
resize>
</frameset>
------------------------------------------------

Here's the javascript in the upper_frame (getcount.php) that's trying to pass the data to lower_frame. It's failing on the first IF statement.

if(parent.lower_frame && parent.lower_frame.frmCount && parent.lower_frame.frmCount.counter){
parent.lower_frame.frmCount.counter.value = parent.upper_frame.getdata.rec_count.value;
parent.lower_frame.frmParams.where_params.value = "";
}

------------------------------------------------

Here's the form in lower_frame that should be receiving the data (including the DIV in case it's relavant).
<DIV id="Floatme" name="Floatme" STYLE="position:absolute;left:10;top:100;width:100;">

<form action="#" id="frmCount" name="frmCount">
<TABLE bordercolor="#666666" border="0" frame="void" rules="cols" cellspacing="0" WIDTH="50" BGCOLOR="#FFFFCC">
<TR><TD align="center" class="homefont">Search<br>Results</TD></TR>
<TR>
<TD align="center">
<input type="text" name="counter" size="4" readonly style="text-align:center">
</TD>
</TR>
</TABLE>
</form>
</DIV>

I replaced "parent." with "top.", but that made no difference. Any help would be greatly appreciated.

kaled

6:55 pm on May 4, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Not sure, but try window.frames.length.

Kaled.

ajonas

7:04 pm on May 4, 2006 (gmt 0)

10+ Year Member



I'm sorry. I don't understand in what capacity I'm supposed to use windows.frames.length. My javascript skills are a little weak.

siMKin

9:32 am on May 5, 2006 (gmt 0)

10+ Year Member



try:
alert(parent.lower_frame.forms[0]);
or
alert(parent.lower_frame.forms['frmCount']);
or
alert(parent.lower_frame.getElementById('frmCount'));

the last one is the best i think, but for it to work, you should alter the form tag accordingly:

<form action="#" id="frmCount" name="frmCount" id="frmCount">