...

View Full Version : Clear input in seperate frame



Taylor_1978
11-01-2006, 03:17 PM
Hi,

I had a page which had iframes in it.

The main page (room.php) had an input text box and when the user would press submit it would send the form information to chatbox.php which was one of the iframes.

When chatbox.php loaded it would clear the input text box in room.php using:


<script type="text/javascript">
function clearField(){
parent.document.forms[1].message.value = "";
parent.document.forms[1].message.focus();
}
</script>


However now I have changed room.php to look like this:



<FRAMESET rows="10%,40%,40%,10%" BORDER=1 FRAMEBORDER=yes FRAMESPACING=0 NORESIZE>
<frame name="menu" src="chat_top.php">
<frameset cols="50%,50%" BORDER=1 FRAMEBORDER=yes FRAMESPACING=0 NORESIZE>
<frame name="tourney" src="tourneyonline.php">
<frame name="tourney2" src="tourney.php">
</frameset>
<frameset cols="75%,25%" BORDER=1 FRAMEBORDER=yes FRAMESPACING=0 NORESIZE>
<frame name="chatbox" src="chat_box.php">
<frame name="online" src="online.php">
</frameset>
<frame name="message" src="chat_bottom.php">
</frameset>


In the chat_box.php, because this would no longer work as the input field is now in the frame "chat_bottom.php", I fiddled around with the javascript but each way I tried would not clear the input field.

This is what I tried:



<script type="text/javascript">
function clearField(){
parent.frames[6].document.forms[0].message.value = "";
parent.frames[6].document.forms[0].message.focus();
}
</script>


I changed forms[1] to [0] as this input is now the first form in the specific page (chat_bottom.php) and I added frames[6] as it is no longer the parent document. I also tried frames[5] figuring it would start counting at 0 like it did the form.

Any ideas what I might be doing wrong?

Thanks!

homerUK
11-01-2006, 03:41 PM
couldn't you give the form elements an id, so it would be

parent.frames[6].document.getElementById("message").value = "";
parent.frames[6].document.getElementById("message").focus();

would that work?

Taylor_1978
11-01-2006, 03:44 PM
Nope.

Tried it with both 5 and 6 as the frames.. neither worked.

Thanks tho.

Taylor_1978
11-01-2006, 03:49 PM
** Sorry for double post **

homerUK
11-01-2006, 03:50 PM
i've not used frames for years, but can you not reference them by their name?

parent.frame.chatbox
or
frame.frame.chatbox

or something?

Taylor_1978
11-01-2006, 03:58 PM
Nope. I've tried:

parent.frames[0].message.document.forms[0].message.value = "";
parent.frames[0].message.document.forms[0].message.focus();

parent.frames.message.document.forms[0].message.value = "";
parent.frames.message.document.forms[0].message.focus();

parent.message.document.forms[0].message.value = "";
parent.message.document.forms[0].message.focus();

parent.frames[0].["message"].document.forms[0].message.value = "";
parent.frames[0].["message"].document.forms[0].message.focus();

parent.frames.["message"].document.forms[0].message.value = "";
parent.frames.["message"].document.forms[0].message.focus();

parent["message"].document.forms[0].message.value = "";
parent["message"].document.forms[0].message.focus();

None work.

homerUK
11-01-2006, 04:08 PM
could it be getting mixed up with the message variable? the frame being named the same as the form field? It's a long shot, but not sure what else to suggest, sorry!

Taylor_1978
11-02-2006, 12:00 PM
Anyone have any ideas?

Taylor_1978
11-13-2006, 02:00 PM
Anyone at all? :(



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum