Page 1 of 1

[SOLVED] How to change frame src?

Posted: Wed Nov 19, 2008 4:02 am
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.

Re: How to change frame src?

Posted: Wed Nov 19, 2008 4:09 am
by aceconcepts
Maybe you should post come code?

Use the code tags if you do post your code.

Re: How to change frame src?

Posted: Wed Nov 19, 2008 4:47 am
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);">
 

Re: How to change frame src?

Posted: Thu Nov 20, 2008 2:51 am
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();">