Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    Regular Coder
    Join Date
    Jun 2003
    Location
    Australia
    Posts
    528
    Thanks
    8
    Thanked 8 Times in 8 Posts

    Clear input in seperate frame

    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:
    Code:
    <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:

    Code:
    <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:

    Code:
    <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!

  • #2
    Regular Coder
    Join Date
    Nov 2002
    Location
    Manchester, UK
    Posts
    533
    Thanks
    4
    Thanked 1 Time in 1 Post
    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?

  • #3
    Regular Coder
    Join Date
    Jun 2003
    Location
    Australia
    Posts
    528
    Thanks
    8
    Thanked 8 Times in 8 Posts
    Nope.

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

    Thanks tho.

  • #4
    Regular Coder
    Join Date
    Jun 2003
    Location
    Australia
    Posts
    528
    Thanks
    8
    Thanked 8 Times in 8 Posts
    ** Sorry for double post **

  • #5
    Regular Coder
    Join Date
    Nov 2002
    Location
    Manchester, UK
    Posts
    533
    Thanks
    4
    Thanked 1 Time in 1 Post
    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?

  • #6
    Regular Coder
    Join Date
    Jun 2003
    Location
    Australia
    Posts
    528
    Thanks
    8
    Thanked 8 Times in 8 Posts
    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.

  • #7
    Regular Coder
    Join Date
    Nov 2002
    Location
    Manchester, UK
    Posts
    533
    Thanks
    4
    Thanked 1 Time in 1 Post
    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!

  • #8
    Regular Coder
    Join Date
    Jun 2003
    Location
    Australia
    Posts
    528
    Thanks
    8
    Thanked 8 Times in 8 Posts
    Anyone have any ideas?

  • #9
    Regular Coder
    Join Date
    Jun 2003
    Location
    Australia
    Posts
    528
    Thanks
    8
    Thanked 8 Times in 8 Posts
    Anyone at all?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •