[SOLVED] How to change frame src?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dEaMOn
Forum Newbie
Posts: 4
Joined: Wed Nov 19, 2008 3:49 am

[SOLVED] How to change frame src?

Post by dEaMOn »

Hi all,

I has 'content' frame which display 'listing.php', within this page, it was included 'search.php'.
Inside 'search.php', it has javascript to change to src of 'content' frame after user press search button.

My problem is the javascript in 'search.php' was not change my 'content' frame src.
It's just reload 'listing.php'. How to change frame src?


Thanks in advance for all replies.
Last edited by dEaMOn on Thu Nov 20, 2008 2:53 am, edited 1 time in total.
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Re: How to change frame src?

Post by aceconcepts »

Maybe you should post come code?

Use the code tags if you do post your code.
dEaMOn
Forum Newbie
Posts: 4
Joined: Wed Nov 19, 2008 3:49 am

Re: How to change frame src?

Post by dEaMOn »

Here is my code.

frameset

Code: Select all

 
<frameset id="top" rows="86,*,33" framespacing="0" frameborder="no">
  <frame name="banner" src="Topmenu.php" scrolling="no">  
  <frameset id="master" cols="5,200,*,5" frameborder="no" framespacing="0">
    <frame name="left_menu" src="leftmenu.php" style="border-right:3px solid #99CCE5" scrolling="no">      
    <frame name="content" src="listing.php" style="border-bottom:3px solid #99CCE5" scrolling="auto">   
  </frameset> 
  <frame name="footer" src="footer.php" scrolling="no">
</frameset>
 
listing.php

Code: Select all

 
<table>
...data...
<?php include_once('search.php'); ?>
</table>
 
search.php

Code: Select all

 
<script language='javascript'>
  function z_IsEnter(e) {
    characterCode = e.keyCode
    if (characterCode == 13) { //if generated character code is equal to ascii 13 (if enter key)
      parent.document.frames['content'].location = 'result.php';
    }
  }
</script>
<input type="text" name="txtSearch" style="width:140px" onkeypress="z_IsEnter(event);">
 
dEaMOn
Forum Newbie
Posts: 4
Joined: Wed Nov 19, 2008 3:49 am

Re: How to change frame src?

Post by dEaMOn »

I can solved my problem now by adding a button and move the code that changed frame source to new function which fire when this button was click.
Then when user press enter in textbox, I just fire the click event of this button and it's work fined.

Here is my code.

Code: Select all

 
<script language='javascript'>
  function z_IsEnter(e) {
    characterCode = e.keyCode
    if (characterCode == 13) { //if generated character code is equal to ascii 13 (if enter key)
      document.getElementById('btnGo').click();
    }
  }
  function z_Go(); {
    self.location = 'result.php'
  }
</script>
<input type="text" name="txtSearch" onkeypress="z_IsEnter(event);">
<input type="button" name="btnGo" onclick="z_Go();">
 
Post Reply